Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
小 白蛋
Nomad
Commits
a9cd8eaf
Commit
a9cd8eaf
authored
6 years ago
by
Michael Schurter
Browse files
Options
Download
Email Patches
Plain Diff
taskrunner: don't lock for immutable fields
parent
158fab68
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
client/allocrunnerv2/taskrunner/task_runner.go
+7
-4
client/allocrunnerv2/taskrunner/task_runner.go
client/allocrunnerv2/taskrunner/task_runner_getters.go
+0
-6
client/allocrunnerv2/taskrunner/task_runner_getters.go
with
7 additions
and
10 deletions
+7
-10
client/allocrunnerv2/taskrunner/task_runner.go
+
7
-
4
View file @
a9cd8eaf
...
...
@@ -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
.
task
Name
,
},
}
}
...
...
@@ -303,7 +306,7 @@ func (tr *TaskRunner) initDriver() error {
driverCtx
:=
driver
.
NewDriverContext
(
alloc
.
Job
.
Name
,
alloc
.
TaskGroup
,
tr
.
Name
()
,
tr
.
task
Name
,
tr
.
allocID
,
tr
.
clientConfig
,
// XXX Why does it need this
tr
.
clientConfig
.
Node
,
// XXX THIS I NEED TO FIX
...
...
This diff is collapsed.
Click to expand it.
client/allocrunnerv2/taskrunner/task_runner_getters.go
+
0
-
6
View file @
a9cd8eaf
...
...
@@ -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
()
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help