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
ad0012ec
Commit
ad0012ec
authored
6 years ago
by
Alex Dadgar
Committed by
Michael Schurter
6 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Remove SetState from interface
parent
39939a1b
Branches unavailable
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
client/allocrunnerv2/taskrunner/artifact_hook.go
+2
-3
client/allocrunnerv2/taskrunner/artifact_hook.go
client/allocrunnerv2/taskrunner/interfaces/events.go
+0
-1
client/allocrunnerv2/taskrunner/interfaces/events.go
client/allocrunnerv2/taskrunner/task_dir_hook.go
+1
-1
client/allocrunnerv2/taskrunner/task_dir_hook.go
client/allocrunnerv2/taskrunner/task_runner.go
+1
-1
client/allocrunnerv2/taskrunner/task_runner.go
with
4 additions
and
6 deletions
+4
-6
client/allocrunnerv2/taskrunner/artifact_hook.go
+
2
-
3
View file @
ad0012ec
...
...
@@ -30,15 +30,14 @@ func (*artifactHook) Name() string {
}
func
(
h
*
artifactHook
)
Prestart
(
ctx
context
.
Context
,
req
*
interfaces
.
TaskPrestartRequest
,
resp
*
interfaces
.
TaskPrestartResponse
)
error
{
h
.
eventEmitter
.
SetState
(
structs
.
TaskStatePending
,
structs
.
NewTaskEvent
(
structs
.
TaskDownloadingArtifacts
))
h
.
eventEmitter
.
EmitEvent
(
structs
.
NewTaskEvent
(
structs
.
TaskDownloadingArtifacts
))
for
_
,
artifact
:=
range
req
.
Task
.
Artifacts
{
//XXX add ctx to GetArtifact to allow cancelling long downloads
if
err
:=
getter
.
GetArtifact
(
req
.
TaskEnv
,
artifact
,
req
.
TaskDir
);
err
!=
nil
{
wrapped
:=
fmt
.
Errorf
(
"failed to download artifact %q: %v"
,
artifact
.
GetterSource
,
err
)
h
.
logger
.
Debug
(
wrapped
.
Error
())
h
.
eventEmitter
.
SetState
(
structs
.
TaskStatePending
,
structs
.
NewTaskEvent
(
structs
.
TaskArtifactDownloadFailed
)
.
SetDownloadError
(
wrapped
))
h
.
eventEmitter
.
EmitEvent
(
structs
.
NewTaskEvent
(
structs
.
TaskArtifactDownloadFailed
)
.
SetDownloadError
(
wrapped
))
return
wrapped
}
}
...
...
This diff is collapsed.
Click to expand it.
client/allocrunnerv2/taskrunner/interfaces/events.go
+
0
-
1
View file @
ad0012ec
...
...
@@ -3,6 +3,5 @@ package interfaces
import
"github.com/hashicorp/nomad/nomad/structs"
type
EventEmitter
interface
{
SetState
(
state
string
,
event
*
structs
.
TaskEvent
)
EmitEvent
(
event
*
structs
.
TaskEvent
)
}
This diff is collapsed.
Click to expand it.
client/allocrunnerv2/taskrunner/task_dir_hook.go
+
1
-
1
View file @
ad0012ec
...
...
@@ -35,7 +35,7 @@ func (h *taskDirHook) Prestart(ctx context.Context, req *interfaces.TaskPrestart
}
// Emit the event that we are going to be building the task directory
h
.
runner
.
SetState
(
""
,
structs
.
NewTaskEvent
(
structs
.
TaskSetup
)
.
SetMessage
(
structs
.
TaskBuildingTaskDir
))
h
.
runner
.
EmitEvent
(
structs
.
NewTaskEvent
(
structs
.
TaskSetup
)
.
SetMessage
(
structs
.
TaskBuildingTaskDir
))
// Build the task directory structure
fsi
:=
h
.
runner
.
driver
.
FSIsolation
()
...
...
This diff is collapsed.
Click to expand it.
client/allocrunnerv2/taskrunner/task_runner.go
+
1
-
1
View file @
ad0012ec
...
...
@@ -507,7 +507,7 @@ func (tr *TaskRunner) SetState(state string, event *structs.TaskEvent) {
taskState
:=
tr
.
state
//XXX REMOVE ME AFTER TESTING
if
state
!
=
""
{
if
state
=
=
""
{
panic
(
"SetState must not be called with an empty state"
)
}
...
...
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