Ignore spurious container-removal errors

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 #18874

Signed-off-by: Matt Heon <mheon@redhat.com>
This commit is contained in:
Matt Heon 2023-09-05 14:30:43 -04:00
parent 0e3b492faa
commit 71549c642f
1 changed files with 6 additions and 2 deletions

View File

@ -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 {
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
}