diff --git a/cli/delete.go b/cli/delete.go index c2ce52a468..641ef3727a 100644 --- a/cli/delete.go +++ b/cli/delete.go @@ -10,6 +10,7 @@ import ( "context" "fmt" "os" + "syscall" "github.com/kata-containers/runtime/pkg/katautils" vc "github.com/kata-containers/runtime/virtcontainers" @@ -75,6 +76,11 @@ func delete(ctx context.Context, containerID string, force bool) error { kataLog.Warnf("Failed to get container, force will not fail: %s", err) return nil } + if err.Error() == syscall.ENOENT.Error() { + kataLog.WithField("container", containerID).Info("skipping delete as container does not exist") + katautils.DelContainerIDMapping(ctx, containerID) + return nil + } return err } diff --git a/cli/kill.go b/cli/kill.go index 60fa41e09e..259a72dd52 100644 --- a/cli/kill.go +++ b/cli/kill.go @@ -108,8 +108,11 @@ func kill(ctx context.Context, containerID, signal string, all bool) error { // Checks the MUST and MUST NOT from OCI runtime specification status, sandboxID, err := getExistingContainerInfo(ctx, containerID) - if err != nil { + if err.Error() == syscall.ENOENT.Error() { + kataLog.WithField("container", containerID).Info("skipping kill as container does not exist") + return nil + } return err }