Skip to content

Commit

Permalink
Storage can remove ErrNotAContainer as well
Browse files Browse the repository at this point in the history
Fixes: containers#11775

[NO TESTS NEEDED] No easy way to cause this problem in CI.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
  • Loading branch information
rhatdan committed Sep 29, 2021
1 parent 453c49c commit c9ea2ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion libpod/runtime_cstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func (r *Runtime) removeStorageContainer(idOrName string, force bool) error {
}

if err := r.store.DeleteContainer(ctr.ID); err != nil {
if errors.Cause(err) == storage.ErrContainerUnknown {
if errors.Cause(err) == storage.ErrNotAContainer || errors.Cause(err) == storage.ErrContainerUnknown {
// Container again gone, no error
logrus.Infof("Storage for container %s already removed", ctr.ID)
return nil
Expand Down
8 changes: 6 additions & 2 deletions libpod/storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,12 @@ func (r *storageService) DeleteContainer(idOrName string) error {
}
err = r.store.DeleteContainer(container.ID)
if err != nil {
logrus.Debugf("Failed to delete container %q: %v", container.ID, err)
return err
if errors.Cause(err) == storage.ErrNotAContainer || errors.Cause(err) == storage.ErrContainerUnknown {
logrus.Infof("Storage for container %s already removed", container.ID)
} else {
logrus.Debugf("Failed to delete container %q: %v", container.ID, err)
return err
}
}
return nil
}
Expand Down

0 comments on commit c9ea2ca

Please sign in to comment.