diff options
author | Matthew Heon <matthew.heon@gmail.com> | 2018-02-27 15:01:29 -0500 |
---|---|---|
committer | Atomic Bot <atomic-devel@projectatomic.io> | 2018-03-01 21:17:51 +0000 |
commit | f02a9cd97547630a944df83e7e02eac11e8a7021 (patch) | |
tree | c026b7a52ebd1998d979abab11d1f526cf1a76fa /libpod/runtime_pod.go | |
parent | 70baafc1c756ba4ebc25c54ac92763bf0b8e91bb (diff) | |
download | podman-f02a9cd97547630a944df83e7e02eac11e8a7021.tar.gz podman-f02a9cd97547630a944df83e7e02eac11e8a7021.tar.bz2 podman-f02a9cd97547630a944df83e7e02eac11e8a7021.zip |
Handle removing containers with active exec sessions
For containers without --force set, an error will be returned
For containers with --force, all pids in the container will be
stopped, first with SIGTERM and then with SIGKILL after a timeout
(this mimics the behavior of stopping a container).
Signed-off-by: Matthew Heon <matthew.heon@gmail.com>
Closes: #412
Approved by: baude
Diffstat (limited to 'libpod/runtime_pod.go')
-rw-r--r-- | libpod/runtime_pod.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/libpod/runtime_pod.go b/libpod/runtime_pod.go index 248cadf09..0debb7924 100644 --- a/libpod/runtime_pod.go +++ b/libpod/runtime_pod.go @@ -101,6 +101,11 @@ func (r *Runtime) RemovePod(p *Pod, removeCtrs, force bool) error { return errors.Wrapf(ErrCtrStateInvalid, "pod %s contains container %s which is running", p.ID(), ctr.ID()) } + // If the container has active exec sessions and force is not set we can't do anything + if len(ctr.state.ExecSessions) != 0 && !force { + return errors.Wrapf(ErrCtrStateInvalid, "pod %s contains container %s which has active exec sessions", p.ID(), ctr.ID()) + } + deps, err := r.state.ContainerInUse(ctr) if err != nil { return err @@ -134,6 +139,12 @@ func (r *Runtime) RemovePod(p *Pod, removeCtrs, force bool) error { return err } } + // If the container has active exec sessions, stop them now + if len(ctr.state.ExecSessions) != 0 { + if err := r.ociRuntime.execStopContainer(ctr, ctr.StopTimeout()); err != nil { + return err + } + } } } |