summaryrefslogtreecommitdiff
path: root/libpod/pod_api.go
diff options
context:
space:
mode:
authorOpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com>2018-12-07 09:06:03 -0800
committerGitHub <noreply@github.com>2018-12-07 09:06:03 -0800
commit5073638d83b4f466fda434e6a06ad8bab9eef321 (patch)
treed33bd9755a879f27b446c9eb2a80613894cbaff7 /libpod/pod_api.go
parentd266460f7bdd8d49835c8228fe16706915f92796 (diff)
parent52098941000794180a358a6983237cc6c4d30fc1 (diff)
downloadpodman-5073638d83b4f466fda434e6a06ad8bab9eef321.tar.gz
podman-5073638d83b4f466fda434e6a06ad8bab9eef321.tar.bz2
podman-5073638d83b4f466fda434e6a06ad8bab9eef321.zip
Merge pull request #1953 from baude/podstoptimeout
add timeout to pod stop
Diffstat (limited to 'libpod/pod_api.go')
-rw-r--r--libpod/pod_api.go17
1 files changed, 13 insertions, 4 deletions
diff --git a/libpod/pod_api.go b/libpod/pod_api.go
index 3d5512e8c..cbac2420f 100644
--- a/libpod/pod_api.go
+++ b/libpod/pod_api.go
@@ -62,7 +62,13 @@ func (p *Pod) Start(ctx context.Context) (map[string]error, error) {
return nil, nil
}
-// Stop stops all containers within a pod that are not already stopped
+// Stop stops all containers within a pod without a timeout. It assumes -1 for
+// a timeout.
+func (p *Pod) Stop(ctx context.Context, cleanup bool) (map[string]error, error) {
+ return p.StopWithTimeout(ctx, cleanup, -1)
+}
+
+// StopWithTimeout stops all containers within a pod that are not already stopped
// Each container will use its own stop timeout
// Only running containers will be stopped. Paused, stopped, or created
// containers will be ignored.
@@ -77,7 +83,7 @@ func (p *Pod) Start(ctx context.Context) (map[string]error, error) {
// containers. The container ID is mapped to the error encountered. The error is
// set to ErrCtrExists
// If both error and the map are nil, all containers were stopped without error
-func (p *Pod) Stop(ctx context.Context, cleanup bool) (map[string]error, error) {
+func (p *Pod) StopWithTimeout(ctx context.Context, cleanup bool, timeout int) (map[string]error, error) {
p.lock.Lock()
defer p.lock.Unlock()
@@ -110,8 +116,11 @@ func (p *Pod) Stop(ctx context.Context, cleanup bool) (map[string]error, error)
ctr.lock.Unlock()
continue
}
-
- if err := ctr.stop(ctr.config.StopTimeout); err != nil {
+ stopTimeout := ctr.config.StopTimeout
+ if timeout > -1 {
+ stopTimeout = uint(timeout)
+ }
+ if err := ctr.stop(stopTimeout); err != nil {
ctr.lock.Unlock()
ctrErrors[ctr.ID()] = err
continue