From 8e78028e2c8d67963dadc5def5619ca69f858034 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 27 Aug 2024 12:02:33 +0200 Subject: [PATCH 1/2] 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 --- 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 d50e787be6..8abd08837e 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 From dc724e5e806833afe0a9cf39b125dc198b612ba7 Mon Sep 17 00:00:00 2001 From: Paul Holzinger Date: Tue, 27 Aug 2024 12:11:32 +0200 Subject: [PATCH 2/2] run: fix detach passthrough and --rmi When we use passthrough logging and the --rmi option should not try to delete the image right away. Simply speak passthough only means do not print the cotnainer id but we should never try to delete the image here as this will be done in the cleanup process. Signed-off-by: Paul Holzinger --- cmd/podman/containers/run.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmd/podman/containers/run.go b/cmd/podman/containers/run.go index 8abd08837e..924f1198ee 100644 --- a/cmd/podman/containers/run.go +++ b/cmd/podman/containers/run.go @@ -237,8 +237,10 @@ func run(cmd *cobra.Command, args []string) error { return err } - if runOpts.Detach && !passthrough { - fmt.Println(report.Id) + if runOpts.Detach { + if !passthrough { + fmt.Println(report.Id) + } return nil } if runRmi {