Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
sandbox: Create and export ProcessListContainer() to the API level
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
Sebastien Boeuf committed Nov 12, 2018
1 parent 3add296 commit b298ec4
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 7 deletions.
8 changes: 1 addition & 7 deletions virtcontainers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions virtcontainers/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions virtcontainers/pkg/vcmock/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions virtcontainers/sandbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit b298ec4

Please sign in to comment.