sandbox: support force stop

When force is true, ignore any guest related errors. This can
be used to stop a sandbox when hypervisor process is dead.

Signed-off-by: Peng Tao <bergwolf@hyper.sh>
This commit is contained in:
Peng Tao
2019-07-19 00:40:34 -07:00
parent 4130913ed7
commit bc4460e12f
12 changed files with 32 additions and 31 deletions

View File

@@ -112,7 +112,7 @@ func delete(ctx context.Context, containerID string, force bool) error {
switch containerType {
case vc.PodSandbox:
if err := deleteSandbox(ctx, sandboxID); err != nil {
if err := deleteSandbox(ctx, sandboxID, force); err != nil {
return err
}
case vc.PodContainer:
@@ -131,7 +131,7 @@ func delete(ctx context.Context, containerID string, force bool) error {
return katautils.DelContainerIDMapping(ctx, containerID)
}
func deleteSandbox(ctx context.Context, sandboxID string) error {
func deleteSandbox(ctx context.Context, sandboxID string, force bool) error {
span, _ := katautils.Trace(ctx, "deleteSandbox")
defer span.Finish()
@@ -141,7 +141,7 @@ func deleteSandbox(ctx context.Context, sandboxID string) error {
}
if oci.StateToOCIState(status.State.State) != oci.StateStopped {
if _, err := vci.StopSandbox(ctx, sandboxID); err != nil {
if _, err := vci.StopSandbox(ctx, sandboxID, force); err != nil {
return err
}
}

View File

@@ -152,7 +152,7 @@ func kill(ctx context.Context, containerID, signal string, all bool) error {
switch containerType {
case vc.PodSandbox:
_, err = vci.StopSandbox(ctx, sandboxID)
_, err = vci.StopSandbox(ctx, sandboxID, signum == syscall.SIGKILL)
case vc.PodContainer:
_, err = vci.StopContainer(ctx, sandboxID, containerID)
default: