mirror of
https://github.com/kemko/nomad.git
synced 2026-01-04 09:25:46 +03:00
@@ -253,18 +253,21 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, e
|
||||
}
|
||||
cmdArgs = append(cmdArgs, "run")
|
||||
|
||||
// Convert underscores to dashes in task names for use in volume names #2358
|
||||
sanitizedName := strings.Replace(task.Name, "_", "-", -1)
|
||||
|
||||
// Mount /alloc
|
||||
allocVolName := fmt.Sprintf("%s-%s-alloc", ctx.AllocID, task.Name)
|
||||
allocVolName := fmt.Sprintf("%s-%s-alloc", ctx.AllocID, sanitizedName)
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--volume=%s,kind=host,source=%s", allocVolName, ctx.TaskDir.SharedAllocDir))
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--mount=volume=%s,target=%s", allocVolName, allocdir.SharedAllocContainerPath))
|
||||
|
||||
// Mount /local
|
||||
localVolName := fmt.Sprintf("%s-%s-local", ctx.AllocID, task.Name)
|
||||
localVolName := fmt.Sprintf("%s-%s-local", ctx.AllocID, sanitizedName)
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--volume=%s,kind=host,source=%s", localVolName, ctx.TaskDir.LocalDir))
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--mount=volume=%s,target=%s", localVolName, allocdir.TaskLocalContainerPath))
|
||||
|
||||
// Mount /secrets
|
||||
secretsVolName := fmt.Sprintf("%s-%s-secrets", ctx.AllocID, task.Name)
|
||||
secretsVolName := fmt.Sprintf("%s-%s-secrets", ctx.AllocID, sanitizedName)
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--volume=%s,kind=host,source=%s", secretsVolName, ctx.TaskDir.SecretsDir))
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--mount=volume=%s,target=%s", secretsVolName, allocdir.TaskSecretsContainerPath))
|
||||
|
||||
@@ -273,13 +276,12 @@ func (d *RktDriver) Start(ctx *ExecContext, task *structs.Task) (DriverHandle, e
|
||||
if enabled := d.config.ReadBoolDefault(rktVolumesConfigOption, rktVolumesConfigDefault); !enabled {
|
||||
return nil, fmt.Errorf("%s is false; cannot use rkt volumes: %+q", rktVolumesConfigOption, driverConfig.Volumes)
|
||||
}
|
||||
|
||||
for i, rawvol := range driverConfig.Volumes {
|
||||
parts := strings.Split(rawvol, ":")
|
||||
if len(parts) != 2 {
|
||||
return nil, fmt.Errorf("invalid rkt volume: %q", rawvol)
|
||||
}
|
||||
volName := fmt.Sprintf("%s-%s-%d", ctx.AllocID, task.Name, i)
|
||||
volName := fmt.Sprintf("%s-%s-%d", ctx.AllocID, sanitizedName, i)
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--volume=%s,kind=host,source=%s", volName, parts[0]))
|
||||
cmdArgs = append(cmdArgs, fmt.Sprintf("--mount=volume=%s,target=%s", volName, parts[1]))
|
||||
}
|
||||
|
||||
@@ -255,7 +255,7 @@ func TestRktDriver_Start_Wait_AllocDir(t *testing.T) {
|
||||
hostpath := filepath.Join(tmpvol, file)
|
||||
|
||||
task := &structs.Task{
|
||||
Name: "alpine",
|
||||
Name: "rkttest_alpine",
|
||||
Driver: "rkt",
|
||||
Config: map[string]interface{}{
|
||||
"image": "docker://alpine",
|
||||
|
||||
Reference in New Issue
Block a user