Skip to content
This repository has been archived by the owner on May 12, 2021. It is now read-only.

Commit

Permalink
runtime: Ignore ENOENT in kill/delete
Browse files Browse the repository at this point in the history
If sandbox/container's dir is not exist, the kill/delete will
always fail,and this make kubelet/container delete it repeatedly
but fail always. In some kind of abnormal
situation(e.g. kill -9 $pidofqemu),
kata-runtime may kill/delete sandbox first, this make container'dir
not exist, so kata-runtime should skip this error.

Fixes: #2959.

Signed-off-by: Shukui Yang <[email protected]>
(cherry picked from commit 120e616)
  • Loading branch information
keloyang authored and amshinde committed Nov 10, 2020
1 parent ebf5f95 commit b71211c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cli/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"context"
"fmt"
"os"
"syscall"

"github.com/kata-containers/runtime/pkg/katautils"
vc "github.com/kata-containers/runtime/virtcontainers"
Expand Down Expand Up @@ -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
}

Expand Down
5 changes: 4 additions & 1 deletion cli/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit b71211c

Please sign in to comment.