summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Vieux <vieux@docker.com>2016-06-12 06:00:15 -0700
committerTonis Tiigi <tonistiigi@gmail.com>2016-06-13 18:22:35 -0700
commitd17b30ba3324715809a7f9d18a8ff753b9e9be7d (patch)
tree85fba3d57a60ee2fb6146132897b10e42802ca5e
parentd5cb43841c8b51bbee8084dea64748e8abcfe04b (diff)
downloaddocker-d17b30ba3324715809a7f9d18a8ff753b9e9be7d.tar.gz
fix mounts
Signed-off-by: Victor Vieux <vieux@docker.com>
-rw-r--r--daemon/cluster/executor/container/adapter.go27
-rw-r--r--daemon/cluster/executor/container/container.go19
2 files changed, 35 insertions, 11 deletions
diff --git a/daemon/cluster/executor/container/adapter.go b/daemon/cluster/executor/container/adapter.go
index 2510a71ca7..c9751caeff 100644
--- a/daemon/cluster/executor/container/adapter.go
+++ b/daemon/cluster/executor/container/adapter.go
@@ -188,17 +188,28 @@ func (c *containerAdapter) remove(ctx context.Context) error {
func (c *containerAdapter) createVolumes(ctx context.Context, backend executorpkg.Backend) error {
// Create plugin volumes that are embedded inside a Mount
for _, mount := range c.container.task.Spec.GetContainer().Mounts {
+ if mount.Type != api.MountTypeVolume {
+ continue
+ }
+
if mount.VolumeOptions != nil {
- req := c.container.volumeCreateRequest(&mount)
+ continue
+ }
- // Check if this volume exists on the engine
- if _, err := backend.VolumeCreate(req.Name, req.Driver, req.DriverOpts, req.Labels); err != nil {
- // TODO(amitshukla): Today, volume create through the engine api does not return an error
- // when the named volume with the same parameters already exists.
- // It returns an error if the driver name is different - that is a valid error
- return err
- }
+ if mount.VolumeOptions.DriverConfig == nil {
+ continue
}
+
+ req := c.container.volumeCreateRequest(&mount)
+
+ // Check if this volume exists on the engine
+ if _, err := backend.VolumeCreate(req.Name, req.Driver, req.DriverOpts, req.Labels); err != nil {
+ // TODO(amitshukla): Today, volume create through the engine api does not return an error
+ // when the named volume with the same parameters already exists.
+ // It returns an error if the driver name is different - that is a valid error
+ return err
+ }
+
}
return nil
diff --git a/daemon/cluster/executor/container/container.go b/daemon/cluster/executor/container/container.go
index a2ff612809..df62c04b2c 100644
--- a/daemon/cluster/executor/container/container.go
+++ b/daemon/cluster/executor/container/container.go
@@ -212,11 +212,24 @@ func (c *containerConfig) hostConfig() *enginecontainer.HostConfig {
// This handles the case of volumes that are defined inside a service Mount
func (c *containerConfig) volumeCreateRequest(mount *api.Mount) *types.VolumeCreateRequest {
+ var (
+ driverName string
+ driverOpts map[string]string
+ labels map[string]string
+ )
+
+ if mount.VolumeOptions != nil && mount.VolumeOptions.DriverConfig != nil {
+ driverName = mount.VolumeOptions.DriverConfig.Name
+ driverOpts = mount.VolumeOptions.DriverConfig.Options
+ labels = mount.VolumeOptions.Labels
+ }
+
if mount.VolumeOptions != nil {
return &types.VolumeCreateRequest{
- // Name ?
- Driver: mount.VolumeOptions.DriverConfig.Name,
- DriverOpts: mount.VolumeOptions.DriverConfig.Options,
+ Name: mount.Source,
+ Driver: driverName,
+ DriverOpts: driverOpts,
+ Labels: labels,
}
}
return nil