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
4dfcc80a
Unverified
Commit
4dfcc80a
authored
6 years ago
by
Nick Ethier
Browse files
Options
Download
Email Patches
Plain Diff
task_runner: use task and alloc copies instead of referencing the original pointer
parent
2393f6a0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
client/allocrunner/taskrunner/task_runner.go
+10
-7
client/allocrunner/taskrunner/task_runner.go
with
10 additions
and
7 deletions
+10
-7
client/allocrunner/taskrunner/task_runner.go
+
10
-
7
View file @
4dfcc80a
...
...
@@ -668,20 +668,23 @@ func (tr *TaskRunner) persistLocalState() error {
// buildTaskConfig builds a drivers.TaskConfig with an unique ID for the task.
// The ID is consistently built from the alloc ID, task name and restart attempt.
func
(
tr
*
TaskRunner
)
buildTaskConfig
()
*
drivers
.
TaskConfig
{
task
:=
tr
.
Task
()
alloc
:=
tr
.
Alloc
()
return
&
drivers
.
TaskConfig
{
ID
:
fmt
.
Sprintf
(
"%s/%s/%d"
,
tr
.
allocID
,
tr
.
taskName
,
tr
.
restartTracker
.
GetCount
()),
Name
:
tr
.
task
.
Name
,
ID
:
fmt
.
Sprintf
(
"%s/%s/%d"
,
alloc
.
ID
,
task
.
Name
,
tr
.
restartTracker
.
GetCount
()),
Name
:
task
.
Name
,
JobName
:
alloc
.
Job
.
Name
,
Resources
:
&
drivers
.
Resources
{
NomadResources
:
tr
.
task
.
Resources
,
NomadResources
:
task
.
Resources
,
LinuxResources
:
&
drivers
.
LinuxResources
{
MemoryLimitBytes
:
int64
(
t
r
.
T
ask
()
.
Resources
.
MemoryMB
)
*
1024
*
1024
,
CPUShares
:
int64
(
t
r
.
T
ask
()
.
Resources
.
CPU
),
PercentTicks
:
float64
(
tr
.
task
.
Resources
.
CPU
)
/
float64
(
tr
.
clientConfig
.
Node
.
Resources
.
CPU
),
MemoryLimitBytes
:
int64
(
task
.
Resources
.
MemoryMB
)
*
1024
*
1024
,
CPUShares
:
int64
(
task
.
Resources
.
CPU
),
PercentTicks
:
float64
(
task
.
Resources
.
CPU
)
/
float64
(
tr
.
clientConfig
.
Node
.
Resources
.
CPU
),
},
},
Env
:
tr
.
envBuilder
.
Build
()
.
Map
(),
User
:
tr
.
task
.
User
,
User
:
task
.
User
,
AllocDir
:
tr
.
taskDir
.
AllocDir
,
StdoutPath
:
tr
.
logmonHookConfig
.
stdoutFifo
,
StderrPath
:
tr
.
logmonHookConfig
.
stderrFifo
,
...
...
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