1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00
moby--moby/volume
Brian Goff 9a2d0bc3ad Fix uneccessary calls to volume.Unmount()
Fixes #22564

When an error occurs on mount, there should not be any call later to
unmount. This can throw off refcounting in the underlying driver
unexpectedly.

Consider these two cases:

```
$ docker run -v foo:/bar busybox true
```

```
$ docker run -v foo:/bar -w /foo busybox true
```

In the first case, if mounting `foo` fails, the volume driver will not
get a call to unmount (this is the incorrect behavior).

In the second case, the volume driver will not get a call to unmount
(correct behavior).

This occurs because in the first case, `/bar` does not exist in the
container, and as such there is no call to `volume.Mount()` during the
`create` phase. It will error out during the `start` phase.

In the second case `/bar` is created before dealing with the volume
because of the `-w`. Because of this, when the volume is being setup
docker will try to copy the image path contents in the volume, in which
case it will attempt to mount the volume and fail. This happens during
the `create` phase. This makes it so the container will not be created
(or at least fully created) and the user gets the error on `create`
instead of `start`. The error handling is different in these two phases.

Changed to only send `unmount` if the volume is mounted.

While investigating the cause of the reported issue I found some odd
behavior in unmount calls so I've cleaned those up a bit here as well.

Signed-off-by: Brian Goff <cpuguy83@gmail.com>
2016-11-10 14:04:08 -05:00
..
drivers Update plugingetter import path in docker/docker. 2016-10-11 11:24:18 -07:00
local #26639: Local NFS volumes do not resolve hostnames 2016-11-08 08:26:53 +00:00
store Fix volume creates blocked by stale cache entries 2016-11-03 11:56:44 -04:00
testutils test: fix trivial code convention noncompliance 2016-09-12 07:36:52 +00:00
validate.go api: fix ReadOnly support for tmpfs 2016-11-08 06:49:17 +00:00
validate_test.go Add new HostConfig field, Mounts. 2016-09-13 09:55:35 -04:00
validate_test_unix.go Add new HostConfig field, Mounts. 2016-09-13 09:55:35 -04:00
validate_test_windows.go Add new HostConfig field, Mounts. 2016-09-13 09:55:35 -04:00
volume.go Fix uneccessary calls to volume.Unmount() 2016-11-10 14:04:08 -05:00
volume_copy.go Add new HostConfig field, Mounts. 2016-09-13 09:55:35 -04:00
volume_copy_unix.go Add new HostConfig field, Mounts. 2016-09-13 09:55:35 -04:00
volume_copy_windows.go Add new HostConfig field, Mounts. 2016-09-13 09:55:35 -04:00
volume_linux.go api: fix ReadOnly support for tmpfs 2016-11-08 06:49:17 +00:00
volume_linux_test.go api: fix ReadOnly support for tmpfs 2016-11-08 06:49:17 +00:00
volume_propagation_linux.go Add new HostConfig field, Mounts. 2016-09-13 09:55:35 -04:00
volume_propagation_linux_test.go Add new HostConfig field, Mounts. 2016-09-13 09:55:35 -04:00
volume_propagation_unsupported.go Add new HostConfig field, Mounts. 2016-09-13 09:55:35 -04:00
volume_test.go Fix volume creates blocked by stale cache entries 2016-11-03 11:56:44 -04:00
volume_unix.go Add new HostConfig field, Mounts. 2016-09-13 09:55:35 -04:00
volume_unsupported.go api: fix ReadOnly support for tmpfs 2016-11-08 06:49:17 +00:00
volume_windows.go Windows: Remove TP5 support from volume 2016-09-21 11:03:19 -07:00