Commit a9cd8eaf authored by Michael Schurter's avatar Michael Schurter
Browse files

taskrunner: don't lock for immutable fields

parent 158fab68
No related merge requests found
Showing with 7 additions and 10 deletions
+7 -10
......@@ -20,8 +20,10 @@ import (
)
type TaskRunner struct {
// allocID is immutable so store a copy to access without locks
allocID string
// allocID and taskName are immutable so store a copy to access without
// locks
allocID string
taskName string
alloc *structs.Allocation
allocLock sync.Mutex
......@@ -108,6 +110,7 @@ func NewTaskRunner(config *Config) (*TaskRunner, error) {
clientConfig: config.ClientConfig,
task: config.Task,
taskDir: config.TaskDir,
taskName: config.Task.Name,
envBuilder: envBuilder,
state: config.State,
ctx: trCtx,
......@@ -173,7 +176,7 @@ func (tr *TaskRunner) initLabels() {
},
{
Name: "task",
Value: tr.Name(),
Value: tr.taskName,
},
}
}
......@@ -303,7 +306,7 @@ func (tr *TaskRunner) initDriver() error {
driverCtx := driver.NewDriverContext(
alloc.Job.Name,
alloc.TaskGroup,
tr.Name(),
tr.taskName,
tr.allocID,
tr.clientConfig, // XXX Why does it need this
tr.clientConfig.Node, // XXX THIS I NEED TO FIX
......
......@@ -2,12 +2,6 @@ package taskrunner
import "github.com/hashicorp/nomad/nomad/structs"
func (tr *TaskRunner) Name() string {
tr.taskLock.RLock()
defer tr.taskLock.RUnlock()
return tr.task.Name
}
func (tr *TaskRunner) Task() *structs.Task {
tr.taskLock.RLock()
defer tr.taskLock.RUnlock()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment