diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2019-12-02 16:31:11 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-02 16:31:11 +0100 |
commit | e4275b3453598c3cdcf1ee00ff73c55780aef444 (patch) | |
tree | 15915f36125dfd9db9d56440f2a89f0610aa52fc /libpod/container_api.go | |
parent | 39c705e9405faa4d02b71165d05eec1e7bb44d93 (diff) | |
parent | 6c405b5fbcc83ba49c187087eb4e1ccc1a7ff147 (diff) | |
download | podman-e4275b3453598c3cdcf1ee00ff73c55780aef444.tar.gz podman-e4275b3453598c3cdcf1ee00ff73c55780aef444.tar.bz2 podman-e4275b3453598c3cdcf1ee00ff73c55780aef444.zip |
Merge pull request #4493 from mheon/add_removing_state
Add ContainerStateRemoving
Diffstat (limited to 'libpod/container_api.go')
-rw-r--r-- | libpod/container_api.go | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go index b8cfe02f6..153a1d628 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -404,6 +404,11 @@ func (c *Container) Mount() (string, error) { return "", err } } + + if c.state.State == define.ContainerStateRemoving { + return "", errors.Wrapf(define.ErrCtrStateInvalid, "cannot mount container %s as it is being removed", c.ID()) + } + defer c.newContainerEvent(events.Mount) return c.mount() } @@ -488,7 +493,12 @@ func (c *Container) Export(path string) error { return err } } - defer c.newContainerEvent(events.Export) + + if c.state.State == define.ContainerStateRemoving { + return errors.Wrapf(define.ErrCtrStateInvalid, "cannot mount container %s as it is being removed", c.ID()) + } + + defer c.newContainerEvent(events.Mount) return c.export(path) } @@ -674,6 +684,10 @@ func (c *Container) Refresh(ctx context.Context) error { } } + if c.state.State == define.ContainerStateRemoving { + return errors.Wrapf(define.ErrCtrStateInvalid, "cannot refresh containers that are being removed") + } + wasCreated := false if c.state.State == define.ContainerStateCreated { wasCreated = true @@ -819,7 +833,6 @@ func (c *Container) Checkpoint(ctx context.Context, options ContainerCheckpointO return err } } - defer c.newContainerEvent(events.Checkpoint) return c.checkpoint(ctx, options) } |