sandbox: Create and export ProcessListContainer() to the API level

In order to support use cases such as containerd-shim-v2 where
we would have a long running process holding the sandbox pointer,
there would be no reason to call into the stateless function
ProcessListContainer(), which would recreate a new sandbox pointer
and the corresponding ones for containers.

Fixes #903

Signed-off-by: Sebastien Boeuf <sebastien.boeuf@intel.com>
This commit is contained in:
Sebastien Boeuf 2018-11-12 14:36:47 -08:00
parent 3add296f78
commit b298ec4228
4 changed files with 20 additions and 7 deletions

View File

@ -702,13 +702,7 @@ func ProcessListContainer(ctx context.Context, sandboxID, containerID string, op
}
defer s.releaseStatelessSandbox()
// Fetch the container.
c, err := s.findContainer(containerID)
if err != nil {
return nil, err
}
return c.processList(options)
return s.ProcessListContainer(containerID, options)
}
// UpdateContainer is the virtcontainers entry point to update

View File

@ -83,6 +83,7 @@ type VCSandbox interface {
StatsContainer(containerID string) (ContainerStats, error)
EnterContainer(containerID string, cmd Cmd) (VCContainer, *Process, error)
UpdateContainer(containerID string, resources specs.LinuxResources) error
ProcessListContainer(containerID string, options ProcessListOptions) (ProcessList, error)
WaitProcess(containerID, processID string) (int32, error)
SignalProcess(containerID, processID string, signal syscall.Signal, all bool) error
WinsizeProcess(containerID, processID string, height, width uint32) error

View File

@ -147,6 +147,11 @@ func (s *Sandbox) UpdateContainer(containerID string, resources specs.LinuxResou
return nil
}
// ProcessListContainer implements the VCSandbox function of the same name.
func (s *Sandbox) ProcessListContainer(containerID string, options vc.ProcessListOptions) (vc.ProcessList, error) {
return nil, nil
}
// WaitProcess implements the VCSandbox function of the same name.
func (s *Sandbox) WaitProcess(containerID, processID string) (int32, error) {
return 0, nil

View File

@ -1383,6 +1383,19 @@ func (s *Sandbox) DeleteContainer(containerID string) (VCContainer, error) {
return c, nil
}
// ProcessListContainer lists every process running inside a specific
// container in the sandbox.
func (s *Sandbox) ProcessListContainer(containerID string, options ProcessListOptions) (ProcessList, error) {
// Fetch the container.
c, err := s.findContainer(containerID)
if err != nil {
return nil, err
}
// Get the process list related to the container.
return c.processList(options)
}
// StatusContainer gets the status of a container
// TODO: update container status properly, see kata-containers/runtime#253
func (s *Sandbox) StatusContainer(containerID string) (ContainerStatus, error) {