summaryrefslogtreecommitdiff
path: root/libpod
diff options
context:
space:
mode:
authorcdoern <cdoern@redhat.com>2021-10-04 10:18:01 -0400
committercdoern <cdoern@redhat.com>2021-10-18 11:39:12 -0400
commit4f7a431daf97f33a40609bd4823ed92ab8aa9ca4 (patch)
tree952877bc10516f3c9abcd05e3fce2ab43e50ee2d /libpod
parent36821d302e3787a42d6eefdbd0bdbb6d9da261fb (diff)
downloadpodman-4f7a431daf97f33a40609bd4823ed92ab8aa9ca4.tar.gz
podman-4f7a431daf97f33a40609bd4823ed92ab8aa9ca4.tar.bz2
podman-4f7a431daf97f33a40609bd4823ed92ab8aa9ca4.zip
Pod Rm Infra Improvements
Made changes so that if the pod contains all exited containers and only infra is running, remove the pod. resolves #11713 Signed-off-by: cdoern <cdoern@redhat.com>
Diffstat (limited to 'libpod')
-rw-r--r--libpod/container_internal.go2
-rw-r--r--libpod/runtime_pod_linux.go3
2 files changed, 2 insertions, 3 deletions
diff --git a/libpod/container_internal.go b/libpod/container_internal.go
index 3f9738411..1c3de526c 100644
--- a/libpod/container_internal.go
+++ b/libpod/container_internal.go
@@ -2079,7 +2079,7 @@ func (c *Container) checkReadyForRemoval() error {
return errors.Wrapf(define.ErrCtrStateInvalid, "container %s is in invalid state", c.ID())
}
- if c.ensureState(define.ContainerStateRunning, define.ContainerStatePaused) {
+ if c.ensureState(define.ContainerStateRunning, define.ContainerStatePaused) && !c.IsInfra() {
return errors.Wrapf(define.ErrCtrStateInvalid, "cannot remove container %s as it is %s - running or paused containers cannot be removed without force", c.ID(), c.state.State.String())
}
diff --git a/libpod/runtime_pod_linux.go b/libpod/runtime_pod_linux.go
index 5036dd680..b0279c453 100644
--- a/libpod/runtime_pod_linux.go
+++ b/libpod/runtime_pod_linux.go
@@ -177,10 +177,9 @@ func (r *Runtime) removePod(ctx context.Context, p *Pod, removeCtrs, force bool)
if err != nil {
return err
}
-
numCtrs := len(ctrs)
- // If the only container in the pod is the pause container, remove the pod and container unconditionally.
+ // If the only running container in the pod is the pause container, remove the pod and container unconditionally.
pauseCtrID := p.state.InfraContainerID
if numCtrs == 1 && ctrs[0].ID() == pauseCtrID {
removeCtrs = true