diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-10-03 06:06:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-03 06:06:14 -0700 |
commit | a3c4ce6717cab56d968fbe1fff0ced19f45c23cb (patch) | |
tree | 41657a47b6edeb8ab4776eddf64cb76f59b2813c /libpod/runtime_ctr.go | |
parent | d5687946f6a0aa14a5326f26ca0ceca68588056f (diff) | |
parent | 978aac665060140f08a5574e3611a17cc98516c0 (diff) | |
download | podman-a3c4ce6717cab56d968fbe1fff0ced19f45c23cb.tar.gz podman-a3c4ce6717cab56d968fbe1fff0ced19f45c23cb.tar.bz2 podman-a3c4ce6717cab56d968fbe1fff0ced19f45c23cb.zip |
Merge pull request #1531 from mheon/add_exited_state
Add ContainerStateExited and OCI delete() in cleanup()
Diffstat (limited to 'libpod/runtime_ctr.go')
-rw-r--r-- | libpod/runtime_ctr.go | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libpod/runtime_ctr.go b/libpod/runtime_ctr.go index 6c487e367..4256a84a0 100644 --- a/libpod/runtime_ctr.go +++ b/libpod/runtime_ctr.go @@ -262,7 +262,8 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool) } } else if !(c.state.State == ContainerStateConfigured || c.state.State == ContainerStateCreated || - c.state.State == ContainerStateStopped) { + c.state.State == ContainerStateStopped || + c.state.State == ContainerStateExited) { return errors.Wrapf(ErrCtrStateInvalid, "cannot remove container %s as it is %s - running or paused containers cannot be removed", c.ID(), c.state.State.String()) } @@ -311,7 +312,7 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool) c.valid = false // Clean up network namespace, cgroups, mounts - if err := c.cleanup(); err != nil { + if err := c.cleanup(ctx); err != nil { if cleanupErr == nil { cleanupErr = err } else { @@ -332,10 +333,11 @@ func (r *Runtime) removeContainer(ctx context.Context, c *Container, force bool) label.ReleaseLabel(c.ProcessLabel()) r.reserveLabels() } - // Delete the container - // Only do this if we're not ContainerStateConfigured - if we are, - // we haven't been created in the runtime yet - if c.state.State != ContainerStateConfigured { + // Delete the container. + // Not needed in Configured and Exited states, where the container + // doesn't exist in the runtime + if c.state.State != ContainerStateConfigured && + c.state.State != ContainerStateExited { if err := c.delete(ctx); err != nil { if cleanupErr == nil { cleanupErr = err |