summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorValentin Rothberg <rothberg@redhat.com>2019-11-20 14:10:48 +0100
committerValentin Rothberg <rothberg@redhat.com>2019-11-25 09:48:13 +0100
commita3d13fb286c39a2d9195b70e4265e5ac0deb6fd3 (patch)
tree1d3289f8c48191ee57c803559d54564f81530ca7 /cmd
parent6187e724353f2d68943f912e0d8fc1d3d3c1f549 (diff)
downloadpodman-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 'cmd')
-rw-r--r--cmd/podman/cliconfig/config.go4
-rw-r--r--cmd/podman/pod_rm.go2
-rw-r--r--cmd/podman/pod_stop.go2
-rw-r--r--cmd/podman/rm.go12
-rw-r--r--cmd/podman/stop.go4
5 files changed, 18 insertions, 6 deletions
diff --git a/cmd/podman/cliconfig/config.go b/cmd/podman/cliconfig/config.go
index 745f49651..27d94f769 100644
--- a/cmd/podman/cliconfig/config.go
+++ b/cmd/podman/cliconfig/config.go
@@ -368,6 +368,7 @@ type PodRestartValues struct {
type PodRmValues struct {
PodmanCommand
All bool
+ Ignore bool
Force bool
Latest bool
}
@@ -389,6 +390,7 @@ type PodStatsValues struct {
type PodStopValues struct {
PodmanCommand
All bool
+ Ignore bool
Latest bool
Timeout uint
}
@@ -484,6 +486,7 @@ type RmValues struct {
PodmanCommand
All bool
Force bool
+ Ignore bool
Latest bool
Storage bool
Volumes bool
@@ -561,6 +564,7 @@ type StatsValues struct {
type StopValues struct {
PodmanCommand
All bool
+ Ignore bool
Latest bool
Timeout uint
CIDFiles []string
diff --git a/cmd/podman/pod_rm.go b/cmd/podman/pod_rm.go
index 86d6d2f27..fcf1d5bc7 100644
--- a/cmd/podman/pod_rm.go
+++ b/cmd/podman/pod_rm.go
@@ -41,7 +41,9 @@ func init() {
flags := podRmCommand.Flags()
flags.BoolVarP(&podRmCommand.All, "all", "a", false, "Remove all running pods")
flags.BoolVarP(&podRmCommand.Force, "force", "f", false, "Force removal of a running pod by first stopping all containers, then removing all containers in the pod. The default is false")
+ flags.BoolVarP(&podRmCommand.Ignore, "ignore", "i", false, "Ignore errors when a specified pod is missing")
flags.BoolVarP(&podRmCommand.Latest, "latest", "l", false, "Remove the latest pod podman is aware of")
+ markFlagHiddenForRemoteClient("ignore", flags)
markFlagHiddenForRemoteClient("latest", flags)
}
diff --git a/cmd/podman/pod_stop.go b/cmd/podman/pod_stop.go
index 579e4f1d3..7d3951ec4 100644
--- a/cmd/podman/pod_stop.go
+++ b/cmd/podman/pod_stop.go
@@ -41,8 +41,10 @@ func init() {
podStopCommand.SetUsageTemplate(UsageTemplate())
flags := podStopCommand.Flags()
flags.BoolVarP(&podStopCommand.All, "all", "a", false, "Stop all running pods")
+ flags.BoolVarP(&podStopCommand.Ignore, "ignore", "i", false, "Ignore errors when a specified pod is missing")
flags.BoolVarP(&podStopCommand.Latest, "latest", "l", false, "Stop the latest pod podman is aware of")
flags.UintVarP(&podStopCommand.Timeout, "timeout", "t", 0, "Seconds to wait for pod stop before killing the container")
+ markFlagHiddenForRemoteClient("ignore", flags)
markFlagHiddenForRemoteClient("latest", flags)
}
diff --git a/cmd/podman/rm.go b/cmd/podman/rm.go
index b3bc8e1b9..e69565e95 100644
--- a/cmd/podman/rm.go
+++ b/cmd/podman/rm.go
@@ -40,14 +40,16 @@ func init() {
rmCommand.SetUsageTemplate(UsageTemplate())
flags := rmCommand.Flags()
flags.BoolVarP(&rmCommand.All, "all", "a", false, "Remove all containers")
+ flags.BoolVarP(&rmCommand.Ignore, "ignore", "i", false, "Ignore errors when a specified container is missing")
flags.BoolVarP(&rmCommand.Force, "force", "f", false, "Force removal of a running or unusable container. The default is false")
flags.BoolVarP(&rmCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
flags.BoolVar(&rmCommand.Storage, "storage", false, "Remove container from storage library")
flags.BoolVarP(&rmCommand.Volumes, "volumes", "v", false, "Remove anonymous volumes associated with the container")
flags.StringArrayVarP(&rmCommand.CIDFiles, "cidfile", "", nil, "Read the container ID from the file")
- markFlagHiddenForRemoteClient("storage", flags)
- markFlagHiddenForRemoteClient("latest", flags)
+ markFlagHiddenForRemoteClient("ignore", flags)
markFlagHiddenForRemoteClient("cidfile", flags)
+ markFlagHiddenForRemoteClient("latest", flags)
+ markFlagHiddenForRemoteClient("storage", flags)
}
// rmCmd removes one or more containers
@@ -58,10 +60,10 @@ func rmCmd(c *cliconfig.RmValues) error {
}
defer runtime.DeferredShutdown(false)
- // Storage conflicts with --all/--latest/--volumes
+ // Storage conflicts with --all/--latest/--volumes/--cidfile/--ignore
if c.Storage {
- if c.All || c.Latest || c.Volumes || c.CIDFiles != nil {
- return errors.Errorf("--storage conflicts with --volumes, --all, --latest and --cidfile")
+ if c.All || c.Ignore || c.Latest || c.Volumes || c.CIDFiles != nil {
+ return errors.Errorf("--storage conflicts with --volumes, --all, --latest, --ignore and --cidfile")
}
}
diff --git a/cmd/podman/stop.go b/cmd/podman/stop.go
index acecb298e..c62da80df 100644
--- a/cmd/podman/stop.go
+++ b/cmd/podman/stop.go
@@ -39,12 +39,14 @@ func init() {
stopCommand.SetUsageTemplate(UsageTemplate())
flags := stopCommand.Flags()
flags.BoolVarP(&stopCommand.All, "all", "a", false, "Stop all running containers")
+ flags.BoolVarP(&stopCommand.Ignore, "ignore", "i", false, "Ignore errors when a specified container is missing")
+ flags.StringArrayVarP(&stopCommand.CIDFiles, "cidfile", "", nil, "Read the container ID from the file")
flags.BoolVarP(&stopCommand.Latest, "latest", "l", false, "Act on the latest container podman is aware of")
flags.UintVar(&stopCommand.Timeout, "time", define.CtrRemoveTimeout, "Seconds to wait for stop before killing the container")
flags.UintVarP(&stopCommand.Timeout, "timeout", "t", define.CtrRemoveTimeout, "Seconds to wait for stop before killing the container")
- flags.StringArrayVarP(&stopCommand.CIDFiles, "cidfile", "", nil, "Read the container ID from the file")
markFlagHiddenForRemoteClient("latest", flags)
markFlagHiddenForRemoteClient("cidfile", flags)
+ markFlagHiddenForRemoteClient("ignore", flags)
}
// stopCmd stops a container or containers