Browse code

Merge pull request #19190 from srust/volume_driver_parity_again

Allow external volume drivers to host anonymous volumes again

Brian Goff authored on 2016/01/23 05:53:06
Showing 4 changed files
... ...
@@ -105,7 +105,7 @@ func (daemon *Daemon) create(params types.ContainerCreateConfig) (retC *containe
105 105
 		}
106 106
 	}()
107 107
 
108
-	if err := daemon.createContainerPlatformSpecificSettings(container, params.Config, params.HostConfig, img); err != nil {
108
+	if err := daemon.createContainerPlatformSpecificSettings(container, params.Config, params.HostConfig); err != nil {
109 109
 		return nil, err
110 110
 	}
111 111
 
... ...
@@ -9,15 +9,13 @@ import (
9 9
 	"github.com/Sirupsen/logrus"
10 10
 	"github.com/docker/docker/container"
11 11
 	derr "github.com/docker/docker/errors"
12
-	"github.com/docker/docker/image"
13 12
 	"github.com/docker/docker/pkg/stringid"
14
-	"github.com/docker/docker/volume"
15 13
 	containertypes "github.com/docker/engine-api/types/container"
16 14
 	"github.com/opencontainers/runc/libcontainer/label"
17 15
 )
18 16
 
19 17
 // createContainerPlatformSpecificSettings performs platform specific container create functionality
20
-func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig, img *image.Image) error {
18
+func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig) error {
21 19
 	if err := daemon.Mount(container); err != nil {
22 20
 		return err
23 21
 	}
... ...
@@ -46,17 +44,7 @@ func (daemon *Daemon) createContainerPlatformSpecificSettings(container *contain
46 46
 			return derr.ErrorCodeMountOverFile.WithArgs(path)
47 47
 		}
48 48
 
49
-		volumeDriver := hostConfig.VolumeDriver
50
-		if destination != "" && img != nil {
51
-			if _, ok := img.ContainerConfig.Volumes[destination]; ok {
52
-				// check for whether bind is not specified and then set to local
53
-				if _, ok := container.MountPoints[destination]; !ok {
54
-					volumeDriver = volume.DefaultDriverName
55
-				}
56
-			}
57
-		}
58
-
59
-		v, err := daemon.volumes.CreateWithRef(name, volumeDriver, container.ID, nil)
49
+		v, err := daemon.volumes.CreateWithRef(name, hostConfig.VolumeDriver, container.ID, nil)
60 50
 		if err != nil {
61 51
 			return err
62 52
 		}
... ...
@@ -4,14 +4,13 @@ import (
4 4
 	"fmt"
5 5
 
6 6
 	"github.com/docker/docker/container"
7
-	"github.com/docker/docker/image"
8 7
 	"github.com/docker/docker/pkg/stringid"
9 8
 	"github.com/docker/docker/volume"
10 9
 	containertypes "github.com/docker/engine-api/types/container"
11 10
 )
12 11
 
13 12
 // createContainerPlatformSpecificSettings performs platform specific container create functionality
14
-func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig, img *image.Image) error {
13
+func (daemon *Daemon) createContainerPlatformSpecificSettings(container *container.Container, config *containertypes.Config, hostConfig *containertypes.HostConfig) error {
15 14
 	for spec := range config.Volumes {
16 15
 
17 16
 		mp, err := volume.ParseMountSpec(spec, hostConfig.VolumeDriver)
... ...
@@ -31,14 +30,6 @@ func (daemon *Daemon) createContainerPlatformSpecificSettings(container *contain
31 31
 		}
32 32
 
33 33
 		volumeDriver := hostConfig.VolumeDriver
34
-		if mp.Destination != "" && img != nil {
35
-			if _, ok := img.ContainerConfig.Volumes[mp.Destination]; ok {
36
-				// check for whether bind is not specified and then set to local
37
-				if _, ok := container.MountPoints[mp.Destination]; !ok {
38
-					volumeDriver = volume.DefaultDriverName
39
-				}
40
-			}
41
-		}
42 34
 
43 35
 		// Create the volume in the volume driver. If it doesn't exist,
44 36
 		// a new one will be created.
... ...
@@ -296,33 +296,6 @@ func hostVolumePath(name string) string {
296 296
 	return fmt.Sprintf("/var/lib/docker/volumes/%s", name)
297 297
 }
298 298
 
299
-func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverNamedCheckBindLocalVolume(c *check.C) {
300
-	err := s.d.StartWithBusybox()
301
-	c.Assert(err, checker.IsNil)
302
-
303
-	expected := s.server.URL
304
-	dockerfile := fmt.Sprintf(`FROM busybox:latest
305
-	RUN mkdir /nobindthenlocalvol
306
-	RUN echo %s > /nobindthenlocalvol/test
307
-	VOLUME ["/nobindthenlocalvol"]`, expected)
308
-
309
-	img := "test-checkbindlocalvolume"
310
-
311
-	_, err = buildImageWithOutInDamon(s.d.sock(), img, dockerfile, true)
312
-	c.Assert(err, checker.IsNil)
313
-
314
-	out, err := s.d.Cmd("run", "--rm", "--name", "test-data-nobind", "-v", "external-volume-test:/tmp/external-volume-test", "--volume-driver", "test-external-volume-driver", img, "cat", "/nobindthenlocalvol/test")
315
-	c.Assert(err, checker.IsNil)
316
-
317
-	c.Assert(out, checker.Contains, expected)
318
-
319
-	c.Assert(s.ec.activations, checker.Equals, 1)
320
-	c.Assert(s.ec.creations, checker.Equals, 1)
321
-	c.Assert(s.ec.removals, checker.Equals, 1)
322
-	c.Assert(s.ec.mounts, checker.Equals, 1)
323
-	c.Assert(s.ec.unmounts, checker.Equals, 1)
324
-}
325
-
326 299
 // Make sure a request to use a down driver doesn't block other requests
327 300
 func (s *DockerExternalVolumeSuite) TestExternalVolumeDriverLookupNotBlocked(c *check.C) {
328 301
 	specPath := "/etc/docker/plugins/down-driver.spec"