aboutsummaryrefslogtreecommitdiff
path: root/cmd/podman/pods
diff options
context:
space:
mode:
authorDaniel J Walsh <dwalsh@redhat.com>2021-09-30 14:43:39 -0400
committerDaniel J Walsh <dwalsh@redhat.com>2021-10-04 07:07:56 -0400
commit21c9dc3c406bb486c44c4a27e5b0497bab1cd40d (patch)
tree56793ffd885f835fa54013e9914844ff9ba20d92 /cmd/podman/pods
parent36821d302e3787a42d6eefdbd0bdbb6d9da261fb (diff)
downloadpodman-21c9dc3c406bb486c44c4a27e5b0497bab1cd40d.tar.gz
podman-21c9dc3c406bb486c44c4a27e5b0497bab1cd40d.tar.bz2
podman-21c9dc3c406bb486c44c4a27e5b0497bab1cd40d.zip
Add --time out for podman * rm -f commands
Add --time flag to podman container rm Add --time flag to podman pod rm Add --time flag to podman volume rm Add --time flag to podman network rm Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Diffstat (limited to 'cmd/podman/pods')
-rw-r--r--cmd/podman/pods/rm.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/cmd/podman/pods/rm.go b/cmd/podman/pods/rm.go
index dc4c7eb83..d8a09d774 100644
--- a/cmd/podman/pods/rm.go
+++ b/cmd/podman/pods/rm.go
@@ -42,6 +42,7 @@ var (
podman pod rm -f 860a4b23
podman pod rm -f -a`,
}
+ stopTimeout uint
)
func init() {
@@ -59,6 +60,10 @@ func init() {
flags.StringArrayVarP(&rmOptions.PodIDFiles, podIDFileFlagName, "", nil, "Read the pod ID from the file")
_ = rmCommand.RegisterFlagCompletionFunc(podIDFileFlagName, completion.AutocompleteDefault)
+ timeFlagName := "time"
+ flags.UintVarP(&stopTimeout, timeFlagName, "t", containerConfig.Engine.StopTimeout, "Seconds to wait for pod stop before killing the container")
+ _ = rmCommand.RegisterFlagCompletionFunc(timeFlagName, completion.AutocompleteNone)
+
validate.AddLatestFlag(rmCommand, &rmOptions.Latest)
if registry.IsRemote() {
@@ -66,12 +71,18 @@ func init() {
}
}
-func rm(_ *cobra.Command, args []string) error {
+func rm(cmd *cobra.Command, args []string) error {
ids, err := specgenutil.ReadPodIDFiles(rmOptions.PodIDFiles)
if err != nil {
return err
}
args = append(args, ids...)
+ if cmd.Flag("time").Changed {
+ if !rmOptions.Force {
+ return errors.New("--force option must be specified to use the --time option")
+ }
+ rmOptions.Timeout = &stopTimeout
+ }
return removePods(args, rmOptions.PodRmOptions, true)
}