diff options
author | Valentin Rothberg <rothberg@redhat.com> | 2019-11-20 14:10:48 +0100 |
---|---|---|
committer | Valentin Rothberg <rothberg@redhat.com> | 2019-11-25 09:48:13 +0100 |
commit | a3d13fb286c39a2d9195b70e4265e5ac0deb6fd3 (patch) | |
tree | 1d3289f8c48191ee57c803559d54564f81530ca7 /pkg/adapter/pods.go | |
parent | 6187e724353f2d68943f912e0d8fc1d3d3c1f549 (diff) | |
download | podman-a3d13fb286c39a2d9195b70e4265e5ac0deb6fd3.tar.gz podman-a3d13fb286c39a2d9195b70e4265e5ac0deb6fd3.tar.bz2 podman-a3d13fb286c39a2d9195b70e4265e5ac0deb6fd3.zip |
podman {pod,} rm/stop: add --ignore flag
Add an --ignore flag to podman rm and stop. When specified, Podman will
ignore "no such {container,pod}" errors that occur when a specified
container/pod is not present in the store (anymore). The motivation
behind adding this flag is to write more robust systemd services using
Podman. A user might have manually decided to remove a container/pod
which would lead to a failure during the `ExecStop` directive of a
systemd service referencing that container/pod.
Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
Diffstat (limited to 'pkg/adapter/pods.go')
-rw-r--r-- | pkg/adapter/pods.go | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/pkg/adapter/pods.go b/pkg/adapter/pods.go index d73a8b21b..e9f3d41a9 100644 --- a/pkg/adapter/pods.go +++ b/pkg/adapter/pods.go @@ -15,6 +15,7 @@ import ( "github.com/containers/libpod/cmd/podman/cliconfig" "github.com/containers/libpod/cmd/podman/shared" "github.com/containers/libpod/libpod" + "github.com/containers/libpod/libpod/define" "github.com/containers/libpod/libpod/image" "github.com/containers/libpod/pkg/adapter/shortcuts" ann "github.com/containers/libpod/pkg/annotations" @@ -94,7 +95,7 @@ func (r *LocalRuntime) RemovePods(ctx context.Context, cli *cliconfig.PodRmValue podids []string ) pods, err := shortcuts.GetPodsByContext(cli.All, cli.Latest, cli.InputArgs, r.Runtime) - if err != nil { + if err != nil && !(cli.Ignore && errors.Cause(err) == define.ErrNoSuchPod) { errs = append(errs, err) return nil, errs } @@ -151,7 +152,7 @@ func (r *LocalRuntime) StopPods(ctx context.Context, cli *cliconfig.PodStopValue podids []string ) pods, err := shortcuts.GetPodsByContext(cli.All, cli.Latest, cli.InputArgs, r.Runtime) - if err != nil { + if err != nil && !(cli.Ignore && errors.Cause(err) == define.ErrNoSuchPod) { errs = append(errs, err) return nil, errs } |