mirror of
https://github.com/aljazceru/kata-containers.git
synced 2026-01-03 22:44:24 +01:00
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:
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user