Skip to content

Commit

Permalink
Remove VolumesFrom feature
Browse files Browse the repository at this point in the history
Since containers are named with alloc ids it's difficult to use safely.
Not to mention task scheduling ordering issues could break it as well.
  • Loading branch information
schmichael committed Oct 7, 2016
1 parent 297d637 commit e876c6c
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions client/driver/docker.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,6 @@ type DockerDriverConfig struct {
WorkDir string `mapstructure:"work_dir"` // Working directory inside the container
Logging []DockerLoggingOpts `mapstructure:"logging"` // Logging options for syslog server
Volumes []string `mapstructure:"volumes"` // Host-Volumes to mount in, syntax: /path/to/host/directory:/destination/path/in/container
VolumesFrom []string `mapstructure:"volumes_from"` // List of volumes-from
}

// Validate validates a docker driver config
Expand Down Expand Up @@ -256,9 +255,6 @@ func (d *DockerDriver) Validate(config map[string]interface{}) error {
"volumes": &fields.FieldSchema{
Type: fields.TypeArray,
},
"volumes_from": &fields.FieldSchema{
Type: fields.TypeArray,
},
},
}

Expand Down Expand Up @@ -397,18 +393,9 @@ func (d *DockerDriver) containerBinds(driverConfig *DockerDriverConfig, alloc *a
secretDirBind := fmt.Sprintf("%s:%s", secret, allocdir.TaskSecretsContainerPath)
binds := []string{allocDirBind, taskLocalBind, secretDirBind}

var merr multierror.Error
volumesEnabled := d.config.ReadBoolDefault(dockerVolumesConfigOption, false)
if len(driverConfig.Volumes) > 0 && !volumesEnabled {
merr.Errors = append(merr.Errors, fmt.Errorf(dockerVolumesConfigOption+" is false; cannot use Docker Volumes: %+q", driverConfig.Volumes))
}

if len(driverConfig.VolumesFrom) > 0 && !volumesEnabled {
merr.Errors = append(merr.Errors, fmt.Errorf(dockerVolumesConfigOption+" is false; cannot use Docker VolumesFrom: %+q", driverConfig.VolumesFrom))
}

if err := merr.ErrorOrNil(); err != nil {
return nil, err
return nil, fmt.Errorf(dockerVolumesConfigOption+" is false; cannot use Docker Volumes: %+q", driverConfig.Volumes)
}

if len(driverConfig.Volumes) > 0 {
Expand Down Expand Up @@ -479,8 +466,7 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task,
// Binds are used to mount a host volume into the container. We mount a
// local directory for storage and a shared alloc directory that can be
// used to share data between different tasks in the same task group.
Binds: binds,
VolumesFrom: driverConfig.VolumesFrom,
Binds: binds,
LogConfig: docker.LogConfig{
Type: driverConfig.Logging[0].Type,
Config: driverConfig.Logging[0].Config,
Expand All @@ -490,9 +476,6 @@ func (d *DockerDriver) createContainer(ctx *ExecContext, task *structs.Task,
d.logger.Printf("[DEBUG] driver.docker: using %d bytes memory for %s", hostConfig.Memory, task.Name)
d.logger.Printf("[DEBUG] driver.docker: using %d cpu shares for %s", hostConfig.CPUShares, task.Name)
d.logger.Printf("[DEBUG] driver.docker: binding directories %#v for %s", hostConfig.Binds, task.Name)
if d.config.ReadBoolDefault(dockerVolumesConfigOption, false) {
d.logger.Printf("[DEBUG] driver.docker: binding Volumes-From: %#v for %s", hostConfig.VolumesFrom, task.Name)
}

// set privileged mode
hostPrivileged := d.config.ReadBoolDefault(dockerPrivilegedConfigOption, false)
Expand Down

0 comments on commit e876c6c

Please sign in to comment.