From 71549c642f01394bf84ca358295aec4ee4aafa80 Mon Sep 17 00:00:00 2001 From: Matt Heon Date: Tue, 5 Sep 2023 14:30:43 -0400 Subject: [PATCH] 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 --- libpod/runtime_ctr.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index f3d8327ac2..49be7aed69 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -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 }