aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorValentin Rothberg <vrothberg@suse.com>2018-10-29 15:11:46 +0100
committerValentin Rothberg <vrothberg@suse.com>2018-10-29 15:46:54 +0100
commit079208cdbc51dd84c06282a84a637ea088b7deb2 (patch)
tree8dc3a895d504b4e4dcafc743a41001fd5066b908
parentaef9d56ae20e34447a69e19613629b8281a78502 (diff)
downloadpodman-079208cdbc51dd84c06282a84a637ea088b7deb2.tar.gz
podman-079208cdbc51dd84c06282a84a637ea088b7deb2.tar.bz2
podman-079208cdbc51dd84c06282a84a637ea088b7deb2.zip
unmount: fix error logic
Only return `ErrCtrStateInvalid` errors when the mount counter is equal to 1. Also fix the "can't unmount [...] last mount[..]" error which hasn't been returned when the error passed to `errors.Errorf()` is nil. Fixes: #1695 Signed-off-by: Valentin Rothberg <vrothberg@suse.com>
-rw-r--r--libpod/container_api.go17
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)