Skip to content

Commit

Permalink
[v5.2-rhel] podman run: ignore image rm error
Browse files Browse the repository at this point in the history
Since commit 458ba5a 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 containers#23719

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
(cherry picked from commit 8e78028)
Signed-off-by: tomsweeneyredhat <tsweeney@redhat.com>
  • Loading branch information
Luap99 authored and TomSweeneyRedHat committed Oct 14, 2024
1 parent a5766aa commit 694f2a4
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions cmd/podman/containers/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 694f2a4

Please sign in to comment.