diff options
author | OpenShift Merge Robot <openshift-merge-robot@users.noreply.github.com> | 2018-10-29 15:29:32 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-10-29 15:29:32 -0700 |
commit | d5b600171d32a20a61d604219c1c230bc0b49343 (patch) | |
tree | fa46744da2cd5877a10f1eff6bf5b54d087bb06d /libpod | |
parent | 5e071f47c08465138cda4fd8929294259cf36bb3 (diff) | |
parent | 079208cdbc51dd84c06282a84a637ea088b7deb2 (diff) | |
download | podman-d5b600171d32a20a61d604219c1c230bc0b49343.tar.gz podman-d5b600171d32a20a61d604219c1c230bc0b49343.tar.bz2 podman-d5b600171d32a20a61d604219c1c230bc0b49343.zip |
Merge pull request #1721 from vrothberg/fix-1695
unmount: fix error logic
Diffstat (limited to 'libpod')
-rw-r--r-- | libpod/container_api.go | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/libpod/container_api.go b/libpod/container_api.go index 41a131ea2..e522038a3 100644 --- a/libpod/container_api.go +++ b/libpod/container_api.go @@ -453,22 +453,19 @@ func (c *Container) Unmount(force bool) error { } } - if c.state.State == ContainerStateRunning || c.state.State == ContainerStatePaused { - return errors.Wrapf(ErrCtrStateInvalid, "cannot unmount storage for container %s as it is running or paused", c.ID()) - } - - // Check if we have active exec sessions - if len(c.state.ExecSessions) != 0 { - return errors.Wrapf(ErrCtrStateInvalid, "container %s has active exec sessions, refusing to unmount", c.ID()) - } - if c.state.Mounted { mounted, err := c.runtime.storageService.MountedContainerImage(c.ID()) if err != nil { return errors.Wrapf(err, "can't determine how many times %s is mounted, refusing to unmount", c.ID()) } if mounted == 1 { - return errors.Wrapf(err, "can't unmount %s last mount, it is still in use", c.ID()) + if c.state.State == ContainerStateRunning || c.state.State == ContainerStatePaused { + return errors.Wrapf(ErrCtrStateInvalid, "cannot unmount storage for container %s as it is running or paused", c.ID()) + } + if len(c.state.ExecSessions) != 0 { + return errors.Wrapf(ErrCtrStateInvalid, "container %s has active exec sessions, refusing to unmount", c.ID()) + } + return errors.Wrapf(ErrInternal, "can't unmount %s last mount, it is still in use", c.ID()) } } return c.unmount(force) |