Skip to content

Commit

Permalink
modified TaskConfig to include AllocID
Browse files Browse the repository at this point in the history
use this for volume names in drivers/rkt to address #1150
  • Loading branch information
Chris Baker committed Nov 26, 2018
1 parent 8cab430 commit 790fe0b
Show file tree
Hide file tree
Showing 6 changed files with 250 additions and 233 deletions.
1 change: 1 addition & 0 deletions client/allocrunner/taskrunner/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -688,6 +688,7 @@ func (tr *TaskRunner) buildTaskConfig() *drivers.TaskConfig {
AllocDir: tr.taskDir.AllocDir,
StdoutPath: tr.logmonHookConfig.stdoutFifo,
StderrPath: tr.logmonHookConfig.stderrFifo,
AllocID: tr.allocID,
}
}

Expand Down
8 changes: 4 additions & 4 deletions drivers/rkt/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -446,17 +446,17 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru
sanitizedName := strings.Replace(cfg.Name, "_", "-", -1)

// Mount /alloc
allocVolName := fmt.Sprintf("%s-%s-alloc", cfg.ID, sanitizedName)
allocVolName := fmt.Sprintf("%s-%s-alloc", cfg.AllocID, sanitizedName)
prepareArgs = append(prepareArgs, fmt.Sprintf("--volume=%s,kind=host,source=%s", allocVolName, cfg.TaskDir().SharedAllocDir))
prepareArgs = append(prepareArgs, fmt.Sprintf("--mount=volume=%s,target=%s", allocVolName, "/alloc"))

// Mount /local
localVolName := fmt.Sprintf("%s-%s-local", cfg.ID, sanitizedName)
localVolName := fmt.Sprintf("%s-%s-local", cfg.AllocID, sanitizedName)
prepareArgs = append(prepareArgs, fmt.Sprintf("--volume=%s,kind=host,source=%s", localVolName, cfg.TaskDir().LocalDir))
prepareArgs = append(prepareArgs, fmt.Sprintf("--mount=volume=%s,target=%s", localVolName, "/local"))

// Mount /secrets
secretsVolName := fmt.Sprintf("%s-%s-secrets", cfg.ID, sanitizedName)
secretsVolName := fmt.Sprintf("%s-%s-secrets", cfg.AllocID, sanitizedName)
prepareArgs = append(prepareArgs, fmt.Sprintf("--volume=%s,kind=host,source=%s", secretsVolName, cfg.TaskDir().SecretsDir))
prepareArgs = append(prepareArgs, fmt.Sprintf("--mount=volume=%s,target=%s", secretsVolName, "/secrets"))

Expand All @@ -481,7 +481,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru
} else if len(parts) != 2 {
return nil, nil, fmt.Errorf("invalid rkt volume: %q", rawvol)
}
volName := fmt.Sprintf("%s-%s-%d", cfg.ID, sanitizedName, i)
volName := fmt.Sprintf("%s-%s-%d", cfg.AllocID, sanitizedName, i)
prepareArgs = append(prepareArgs, fmt.Sprintf("--volume=%s,kind=host,source=%s,readOnly=%s", volName, parts[0], readOnly))
prepareArgs = append(prepareArgs, fmt.Sprintf("--mount=volume=%s,target=%s", volName, parts[1]))
}
Expand Down
1 change: 1 addition & 0 deletions plugins/drivers/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ type TaskConfig struct {
rawDriverConfig []byte
StdoutPath string
StderrPath string
AllocID string
}

func (tc *TaskConfig) Copy() *TaskConfig {
Expand Down
Loading

0 comments on commit 790fe0b

Please sign in to comment.