From 32848b95f6fcf9e8dcd51f23f43846d66886f1ac Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Tue, 26 Jul 2022 06:41:08 -0400 Subject: When removing objects specifying --force,podman should exit with 0 This Patch will cause podman COMMAND rm --force bogus not fail This is how Docker works, so Podman should follow this to allow existing scripts to convert from Docker to Podman. Fixes: #14612 Oprignal version of this patch came from wufan 1991849113@qq.com Signed-off-by: Daniel J Walsh --- cmd/podman/volumes/rm.go | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'cmd/podman/volumes') diff --git a/cmd/podman/volumes/rm.go b/cmd/podman/volumes/rm.go index c160b8623..1383da279 100644 --- a/cmd/podman/volumes/rm.go +++ b/cmd/podman/volumes/rm.go @@ -65,6 +65,9 @@ func rm(cmd *cobra.Command, args []string) error { } responses, err := registry.ContainerEngine().VolumeRm(context.Background(), args, rmOptions) if err != nil { + if rmOptions.Force && strings.Contains(err.Error(), define.ErrNoSuchVolume.Error()) { + return nil + } setExitCode(err) return err } @@ -72,6 +75,9 @@ func rm(cmd *cobra.Command, args []string) error { if r.Err == nil { fmt.Println(r.Id) } else { + if rmOptions.Force && strings.Contains(r.Err.Error(), define.ErrNoSuchVolume.Error()) { + continue + } setExitCode(r.Err) errs = append(errs, r.Err) } -- cgit v1.2.3-54-g00ecf