Skip to content

Commit

Permalink
Merge pull request #395 from hashicorp/f-allocid
Browse files Browse the repository at this point in the history
Passing in the AllocID to exec context
  • Loading branch information
diptanu committed Nov 6, 2015
2 parents 10092b5 + fb8f922 commit 1594cec
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion client/alloc_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ func (r *AllocRunner) Run() {
r.setStatus(structs.AllocClientStatusFailed, fmt.Sprintf("failed to build task dirs for '%s'", alloc.TaskGroup))
return
}
r.ctx = driver.NewExecContext(allocDir)
r.ctx = driver.NewExecContext(allocDir, r.alloc.ID)
}

// Start the task runners
Expand Down
7 changes: 5 additions & 2 deletions client/driver/driver.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,14 @@ type ExecContext struct {

// AllocDir contains information about the alloc directory structure.
AllocDir *allocdir.AllocDir

// Alloc ID
AllocID string
}

// NewExecContext is used to create a new execution context
func NewExecContext(alloc *allocdir.AllocDir) *ExecContext {
return &ExecContext{AllocDir: alloc}
func NewExecContext(alloc *allocdir.AllocDir, allocID string) *ExecContext {
return &ExecContext{AllocDir: alloc, AllocID: allocID}
}

// TaskEnvironmentVariables converts exec context and task configuration into a
Expand Down
2 changes: 1 addition & 1 deletion client/driver/driver_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ func testDriverContext(task string) *DriverContext {
func testDriverExecContext(task *structs.Task, driverCtx *DriverContext) *ExecContext {
allocDir := allocdir.NewAllocDir(filepath.Join(driverCtx.config.AllocDir, structs.GenerateUUID()))
allocDir.Build([]*structs.Task{task})
ctx := NewExecContext(allocDir)
ctx := NewExecContext(allocDir, "dummyAllocId")
return ctx
}

Expand Down
2 changes: 1 addition & 1 deletion client/task_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func testTaskRunner() (*MockTaskStateUpdater, *TaskRunner) {
allocDir := allocdir.NewAllocDir(filepath.Join(conf.AllocDir, alloc.ID))
allocDir.Build([]*structs.Task{task})

ctx := driver.NewExecContext(allocDir)
ctx := driver.NewExecContext(allocDir, alloc.ID)
rp := structs.NewRestartPolicy(structs.JobTypeService)
restartTracker := newRestartTracker(structs.JobTypeService, rp)
tr := NewTaskRunner(logger, conf, upd.Update, ctx, alloc.ID, task, restartTracker)
Expand Down

0 comments on commit 1594cec

Please sign in to comment.