mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-07-04 02:56:18 +00:00
sandbox: Create and export KillContainer() 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 KillContainer(), 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
76537265cb
commit
3add296f78
@ -655,19 +655,7 @@ func KillContainer(ctx context.Context, sandboxID, containerID string, signal sy
|
||||
}
|
||||
defer s.releaseStatelessSandbox()
|
||||
|
||||
// Fetch the container.
|
||||
c, err := s.findContainer(containerID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Send a signal to the process.
|
||||
err = c.kill(signal, all)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
return s.KillContainer(containerID, signal, all)
|
||||
}
|
||||
|
||||
// PauseSandbox is the virtcontainers pausing entry point which pauses an
|
||||
|
@ -78,6 +78,7 @@ type VCSandbox interface {
|
||||
DeleteContainer(contID string) (VCContainer, error)
|
||||
StartContainer(containerID string) (VCContainer, error)
|
||||
StopContainer(containerID string) (VCContainer, error)
|
||||
KillContainer(containerID string, signal syscall.Signal, all bool) error
|
||||
StatusContainer(containerID string) (ContainerStatus, error)
|
||||
StatsContainer(containerID string) (ContainerStats, error)
|
||||
EnterContainer(containerID string, cmd Cmd) (VCContainer, *Process, error)
|
||||
|
@ -112,6 +112,11 @@ func (s *Sandbox) StopContainer(contID string) (vc.VCContainer, error) {
|
||||
return &Container{}, nil
|
||||
}
|
||||
|
||||
// KillContainer implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) KillContainer(contID string, signal syscall.Signal, all bool) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// StatusContainer implements the VCSandbox function of the same name.
|
||||
func (s *Sandbox) StatusContainer(contID string) (vc.ContainerStatus, error) {
|
||||
return vc.ContainerStatus{}, nil
|
||||
|
@ -1336,6 +1336,18 @@ func (s *Sandbox) StopContainer(containerID string) (VCContainer, error) {
|
||||
return c, nil
|
||||
}
|
||||
|
||||
// KillContainer signals a container in the sandbox
|
||||
func (s *Sandbox) KillContainer(containerID string, signal syscall.Signal, all bool) error {
|
||||
// Fetch the container.
|
||||
c, err := s.findContainer(containerID)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Send a signal to the process.
|
||||
return c.kill(signal, all)
|
||||
}
|
||||
|
||||
// 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