mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 11:06:21 +00:00
sandbox: Create and export StopContainer() 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 StopContainer(), 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:
parent
109e12aa56
commit
76537265cb
@ -502,19 +502,7 @@ func StopContainer(ctx context.Context, sandboxID, containerID string) (VCContai
|
||||
}
|
||||
defer s.releaseStatelessSandbox()
|
||||
|
||||
// Fetch the container.
|
||||
c, err := s.findContainer(containerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Stop it.
|
||||
err = c.stop()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return c, nil
|
||||
return s.StopContainer(containerID)
|
||||
}
|
||||
|
||||
// EnterContainer is the virtcontainers container command execution entry point.
|
||||
|
@ -77,6 +77,7 @@ type VCSandbox interface {
|
||||
CreateContainer(contConfig ContainerConfig) (VCContainer, error)
|
||||
DeleteContainer(contID string) (VCContainer, error)
|
||||
StartContainer(containerID string) (VCContainer, error)
|
||||
StopContainer(containerID string) (VCContainer, error)
|
||||
StatusContainer(containerID string) (ContainerStatus, error)
|
||||
StatsContainer(containerID string) (ContainerStats, error)
|
||||
EnterContainer(containerID string, cmd Cmd) (VCContainer, *Process, error)
|
||||
|
@ -107,6 +107,11 @@ func (s *Sandbox) StartContainer(contID string) (vc.VCContainer, error) {
|
||||
return &Container{}, nil
|
||||
}
|
||||
|
||||
// StopContainer implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) StopContainer(contID string) (vc.VCContainer, error) {
|
||||
return &Container{}, nil
|
||||
}
|
||||
|
||||
// StatusContainer implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) StatusContainer(contID string) (vc.ContainerStatus, error) {
|
||||
return vc.ContainerStatus{}, nil
|
||||
|
@ -1320,6 +1320,22 @@ func (s *Sandbox) StartContainer(containerID string) (VCContainer, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// StopContainer stops a container in the sandbox
|
||||
func (s *Sandbox) StopContainer(containerID string) (VCContainer, error) {
|
||||
// Fetch the container.
|
||||
c, err := s.findContainer(containerID)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
// Stop it.
|
||||
if err := c.stop(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// DeleteContainer deletes a container from the sandbox
|
||||
func (s *Sandbox) DeleteContainer(containerID string) (VCContainer, error) {
|
||||
if containerID == "" {
|
||||
|
Loading…
Reference in New Issue
Block a user