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

Commit

Permalink
Merge pull request #1220 from jcvenegas/delete-force-not-fail-non-con…
Browse files Browse the repository at this point in the history
…tainer

delete: force: Do not fail on non exiting container
  • Loading branch information
bergwolf authored Feb 19, 2019
2 parents 731ff7b + c78d6b0 commit 22cee2d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions cli/delete.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ func delete(ctx context.Context, containerID string, force bool) error {
// Checks the MUST and MUST NOT from OCI runtime specification
status, sandboxID, err := getExistingContainerInfo(ctx, containerID)
if err != nil {
if force {
kataLog.Warnf("Failed to get container, force will not fail: %s", err)
return nil
}
return err
}

Expand Down
4 changes: 4 additions & 0 deletions cli/delete_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ func TestDeleteInvalidContainer(t *testing.T) {
err = delete(context.Background(), testContainerID, false)
assert.Error(err)
assert.False(vcmock.IsMockError(err))

// Force to delete missing container
err = delete(context.Background(), "non-existing-test", true)
assert.NoError(err)
}

func TestDeleteMissingContainerTypeAnnotation(t *testing.T) {
Expand Down

0 comments on commit 22cee2d

Please sign in to comment.