diff --git a/cmd/podman/pods/rm.go b/cmd/podman/pods/rm.go index 69eeae21fd..9251ff9ebe 100644 --- a/cmd/podman/pods/rm.go +++ b/cmd/podman/pods/rm.go @@ -113,7 +113,10 @@ func removePods(namesOrIDs []string, rmOptions entities.PodRmOptions, printIDs b return nil } setExitCode(err) - return append(errs, err) + errs = append(errs, err) + if !strings.Contains(err.Error(), define.ErrRemovingCtrs.Error()) { + return errs + } } // in the cli, first we print out all the successful attempts diff --git a/libpod/define/errors.go b/libpod/define/errors.go index be471c27e3..9849660042 100644 --- a/libpod/define/errors.go +++ b/libpod/define/errors.go @@ -211,4 +211,8 @@ var ( // ErrConmonVersionFormat is used when the expected version format of conmon // has changed. ErrConmonVersionFormat = "conmon version changed format" + + // ErrRemovingCtrs indicates that there was an error removing all + // containers from a pod. + ErrRemovingCtrs = errors.New("removing pod containers") ) diff --git a/libpod/runtime_pod_common.go b/libpod/runtime_pod_common.go index 22375c4616..56c8a6153f 100644 --- a/libpod/runtime_pod_common.go +++ b/libpod/runtime_pod_common.go @@ -248,7 +248,7 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool, } if len(ctrErrors) > 0 { - return removedCtrs, fmt.Errorf("not all containers could be removed from pod %s: %w", p.ID(), define.ErrCtrExists) + return removedCtrs, fmt.Errorf("not all containers could be removed from pod %s: %w", p.ID(), define.ErrRemovingCtrs) } } diff --git a/pkg/specgen/generate/container_create.go b/pkg/specgen/generate/container_create.go index 6ce2eea2ca..65143ca641 100644 --- a/pkg/specgen/generate/container_create.go +++ b/pkg/specgen/generate/container_create.go @@ -79,7 +79,7 @@ func MakeContainer(ctx context.Context, rt *libpod.Runtime, s *specgen.SpecGener compatibleOptions := &libpod.InfraInherit{} var infraSpec *specs.Spec if infra != nil { - options, infraSpec, compatibleOptions, err = Inherit(*infra, s, rt) + options, infraSpec, compatibleOptions, err = Inherit(infra, s, rt) if err != nil { return nil, nil, nil, err } @@ -636,7 +636,7 @@ func createContainerOptions(rt *libpod.Runtime, s *specgen.SpecGenerator, pod *l return options, nil } -func Inherit(infra libpod.Container, s *specgen.SpecGenerator, rt *libpod.Runtime) (opts []libpod.CtrCreateOption, infraS *specs.Spec, compat *libpod.InfraInherit, err error) { +func Inherit(infra *libpod.Container, s *specgen.SpecGenerator, rt *libpod.Runtime) (opts []libpod.CtrCreateOption, infraS *specs.Spec, compat *libpod.InfraInherit, err error) { inheritSpec := &specgen.SpecGenerator{} _, compatibleOptions, err := ConfigToSpec(rt, inheritSpec, infra.ID()) if err != nil {