From 694f2a492eb14eeb54efb5da430d74f832aed699 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 27 Aug 2024 12:02:33 +0200 Subject: [PATCH] [v5.2-rhel] podman run: ignore image rm error Since commit 458ba5a8af the cleanup process now removes the image as well, thus the removal is racy and it will cause an error here. The code tried to ignore the error with errors.Is() but this never works across the remote API. However the API already has a ignore option so juts use that and fix the error message so that we can easily find the root cause and I do not have to guess where the log was written. Fixes #23719 Signed-off-by: Paul Holzinger (cherry picked from commit 8e78028e2c8d67963dadc5def5619ca69f858034) Signed-off-by: tomsweeneyredhat --- cmd/podman/containers/run.go | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go index d50e787be6fd..8abd08837e55 100644 --- a/cmd/podman/containers/run.go +++ b/cmd/podman/containers/run.go @@ -16,7 +16,6 @@ import ( "github.com/containers/podman/v5/pkg/rootless" "github.com/containers/podman/v5/pkg/specgen" "github.com/containers/podman/v5/pkg/specgenutil" - "github.com/containers/storage/types" "github.com/sirupsen/logrus" "github.com/spf13/cobra" "golang.org/x/term" @@ -243,13 +242,9 @@ func run(cmd *cobra.Command, args []string) error { return nil } if runRmi { - _, rmErrors := registry.ImageEngine().Remove(registry.GetContext(), []string{imageName}, entities.ImageRemoveOptions{}) + _, rmErrors := registry.ImageEngine().Remove(registry.GetContext(), []string{imageName}, entities.ImageRemoveOptions{Ignore: true}) for _, err := range rmErrors { - // ImageUnknown would be a super-unlikely race - if !errors.Is(err, types.ErrImageUnknown) { - // Typical case: ErrImageUsedByContainer - logrus.Warn(err) - } + logrus.Warnf("Failed to remove image: %v", err) } } return nil