summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorMatthew Heon <matthew.heon@pm.me>2019-02-27 16:17:39 -0500
committerMatthew Heon <matthew.heon@pm.me>2019-02-27 16:20:11 -0500
commit512245afcbf087bab63874040308457e4979b78d (patch)
tree9bea7f6a9b2939227ef93f6a1672d0f9a5af53e7 /cmd
parent70d3cc2e73caf64fc978c1349da45c9a5551b210 (diff)
downloadpodman-512245afcbf087bab63874040308457e4979b78d.tar.gz
podman-512245afcbf087bab63874040308457e4979b78d.tar.bz2
podman-512245afcbf087bab63874040308457e4979b78d.zip
Fix ignored --stop-timeout flag to 'podman create'
Also add some extra debug information to help figure out what's going on when stop goes bad. Fixes: #2472 Signed-off-by: Matthew Heon <matthew.heon@pm.me>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/podman/common.go2
-rw-r--r--cmd/podman/stop.go14
2 files changed, 12 insertions, 4 deletions
diff --git a/cmd/podman/common.go b/cmd/podman/common.go
index e297f3921..f9dfa3759 100644
--- a/cmd/podman/common.go
+++ b/cmd/podman/common.go
@@ -415,7 +415,7 @@ func getCreateFlags(c *cliconfig.PodmanCommand) {
"stop-signal", "",
"Signal to stop a container. Default is SIGTERM",
)
- createFlags.Int(
+ createFlags.Uint(
"stop-timeout", libpod.CtrRemoveTimeout,
"Timeout (in seconds) to stop a container. Default is 10",
)
diff --git a/cmd/podman/stop.go b/cmd/podman/stop.go
index d86894a6f..ab9a2cf38 100644
--- a/cmd/podman/stop.go
+++ b/cmd/podman/stop.go
@@ -73,21 +73,29 @@ func stopCmd(c *cliconfig.StopValues) error {
fmt.Println(err.Error())
}
+ if c.Flag("timeout").Changed && c.Flag("time").Changed {
+ return errors.New("the --timeout and --time flags are mutually exclusive")
+ }
+
var stopFuncs []shared.ParallelWorkerInput
for _, ctr := range containers {
con := ctr
var stopTimeout uint
- if c.Flag("timeout").Changed {
+ if c.Flag("timeout").Changed || c.Flag("time").Changed {
stopTimeout = c.Timeout
} else {
stopTimeout = ctr.StopTimeout()
+ logrus.Debugf("Set timeout to container %s default (%d)", ctr.ID(), stopTimeout)
}
f := func() error {
- if err := con.StopWithTimeout(stopTimeout); err != nil && errors.Cause(err) != libpod.ErrCtrStopped {
+ if err := con.StopWithTimeout(stopTimeout); err != nil {
+ if errors.Cause(err) == libpod.ErrCtrStopped {
+ logrus.Debugf("Container %s already stopped", con.ID())
+ return nil
+ }
return err
}
return nil
-
}
stopFuncs = append(stopFuncs, shared.ParallelWorkerInput{
ContainerID: con.ID(),