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>
This commit is contained in:
cdoern
2021-10-04 10:18:01 -04:00
parent 36821d302e
commit 4f7a431daf
4 changed files with 20 additions and 4 deletions

View File

@ -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())
}