Skip to content

Commit 790fe0b

Browse files
author
Chris Baker
committed
modified TaskConfig to include AllocID
use this for volume names in drivers/rkt to address hashicorp#1150
1 parent 8cab430 commit 790fe0b

File tree

6 files changed

+250
-233
lines changed

6 files changed

+250
-233
lines changed

client/allocrunner/taskrunner/task_runner.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -688,6 +688,7 @@ func (tr *TaskRunner) buildTaskConfig() *drivers.TaskConfig {
688688
AllocDir: tr.taskDir.AllocDir,
689689
StdoutPath: tr.logmonHookConfig.stdoutFifo,
690690
StderrPath: tr.logmonHookConfig.stderrFifo,
691+
AllocID: tr.allocID,
691692
}
692693
}
693694

drivers/rkt/driver.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -446,17 +446,17 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru
446446
sanitizedName := strings.Replace(cfg.Name, "_", "-", -1)
447447

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

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

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

@@ -481,7 +481,7 @@ func (d *Driver) StartTask(cfg *drivers.TaskConfig) (*drivers.TaskHandle, *cstru
481481
} else if len(parts) != 2 {
482482
return nil, nil, fmt.Errorf("invalid rkt volume: %q", rawvol)
483483
}
484-
volName := fmt.Sprintf("%s-%s-%d", cfg.ID, sanitizedName, i)
484+
volName := fmt.Sprintf("%s-%s-%d", cfg.AllocID, sanitizedName, i)
485485
prepareArgs = append(prepareArgs, fmt.Sprintf("--volume=%s,kind=host,source=%s,readOnly=%s", volName, parts[0], readOnly))
486486
prepareArgs = append(prepareArgs, fmt.Sprintf("--mount=volume=%s,target=%s", volName, parts[1]))
487487
}

plugins/drivers/driver.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ type TaskConfig struct {
115115
rawDriverConfig []byte
116116
StdoutPath string
117117
StderrPath string
118+
AllocID string
118119
}
119120

120121
func (tc *TaskConfig) Copy() *TaskConfig {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy