Skip to content

Commit

Permalink
Ignore spurious container-removal errors
Browse files Browse the repository at this point in the history
When removing a container's dependency, getting an error that the
container has already been removed (ErrNoSuchCtr and
ErrCtrRemoved) should not be fatal. We wanted the container gone,
it's gone, no need to error out.

[NO NEW TESTS NEEDED] This is a race and thus hard to test for.

Fixes containers#18874

Signed-off-by: Matt Heon <mheon@redhat.com>
  • Loading branch information
mheon committed Sep 5, 2023
1 parent 0e3b492 commit 71549c6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions libpod/runtime_ctr.go
Original file line number Diff line number Diff line change
Expand Up @@ -916,12 +916,16 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, opts ctrRmO
}
ctrs, pods, err := r.removeContainer(ctx, dep, recursiveOpts)
for rmCtr, err := range ctrs {
removedCtrs[rmCtr] = err
if errors.Is(err, define.ErrNoSuchCtr) || errors.Is(err, define.ErrCtrRemoved) {
removedCtrs[rmCtr] = nil
} else {
removedCtrs[rmCtr] = err
}
}
for rmPod, err := range pods {
removedPods[rmPod] = err
}
if err != nil {
if err != nil && !errors.Is(err, define.ErrNoSuchCtr) && !errors.Is(err, define.ErrCtrRemoved) {
retErr = err
return
}
Expand Down

0 comments on commit 71549c6

Please sign in to comment.