mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 11:06:21 +00:00
sandbox: Create and export Pause/ResumeContainer() 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 functions PauseContainer() and ResumeContainer(), 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
b298ec4228
commit
57773816b3
@ -784,17 +784,11 @@ func togglePauseContainer(ctx context.Context, sandboxID, containerID string, pa
|
||||
}
|
||||
defer s.releaseStatelessSandbox()
|
||||
|
||||
// Fetch the container.
|
||||
c, err := s.findContainer(containerID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if pause {
|
||||
return c.pause()
|
||||
return s.PauseContainer(containerID)
|
||||
}
|
||||
|
||||
return c.resume()
|
||||
return s.ResumeContainer(containerID)
|
||||
}
|
||||
|
||||
// PauseContainer is the virtcontainers container pause entry point.
|
||||
|
@ -81,6 +81,8 @@ type VCSandbox interface {
|
||||
KillContainer(containerID string, signal syscall.Signal, all bool) error
|
||||
StatusContainer(containerID string) (ContainerStatus, error)
|
||||
StatsContainer(containerID string) (ContainerStats, error)
|
||||
PauseContainer(containerID string) error
|
||||
ResumeContainer(containerID string) error
|
||||
EnterContainer(containerID string, cmd Cmd) (VCContainer, *Process, error)
|
||||
UpdateContainer(containerID string, resources specs.LinuxResources) error
|
||||
ProcessListContainer(containerID string, options ProcessListOptions) (ProcessList, error)
|
||||
|
@ -127,6 +127,16 @@ func (s *Sandbox) StatsContainer(contID string) (vc.ContainerStats, error) {
|
||||
return vc.ContainerStats{}, nil
|
||||
}
|
||||
|
||||
// PauseContainer implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) PauseContainer(contID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// ResumeContainer implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) ResumeContainer(contID string) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// Status implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) Status() vc.SandboxStatus {
|
||||
return vc.SandboxStatus{}
|
||||
|
@ -1463,6 +1463,30 @@ func (s *Sandbox) StatsContainer(containerID string) (ContainerStats, error) {
|
||||
return *stats, nil
|
||||
}
|
||||
|
||||
// PauseContainer pauses a running container.
|
||||
func (s *Sandbox) PauseContainer(containerID string) error {
|
||||
// Fetch the container.
|
||||
c, err := s.findContainer(containerID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Pause the container.
|
||||
return c.pause()
|
||||
}
|
||||
|
||||
// ResumeContainer resumes a paused container.
|
||||
func (s *Sandbox) ResumeContainer(containerID string) error {
|
||||
// Fetch the container.
|
||||
c, err := s.findContainer(containerID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Resume the container.
|
||||
return c.resume()
|
||||
}
|
||||
|
||||
// createContainers registers all containers to the proxy, create the
|
||||
// containers in the guest and starts one shim per container.
|
||||
func (s *Sandbox) createContainers() error {
|
||||
|
Loading…
Reference in New Issue
Block a user