Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
lgfa29 committed Aug 24, 2022
1 parent e620cd1 commit 8037a17
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 11 deletions.
10 changes: 5 additions & 5 deletions client/allocrunner/taskrunner/task_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,10 @@ func (tr *TaskRunner) Run() {
runComplete := tr.localState.RunComplete
tr.stateLock.RUnlock()

// If restoring a dead task, ensure that task is cleared and all post hooks
// are called without additional state updates.
// If the alloc is not terminal we must proceed until the ALLOC_RESTART
// loop to allow the task to run again in case the alloc is restarted.
// If restoring a dead task, ensure the task is cleared and, if the local
// state indicates that the previous Run() call is complete, execute all
// post stop hooks and exit early, otherwise proceed until the
// ALLOC_RESTART loop skipping MAIN since the task is dead.
if dead {
// do cleanup functions without emitting any additional events/work
// to handle cases where we restored a dead task where client terminated
Expand Down Expand Up @@ -686,7 +686,7 @@ MAIN:
tr.UpdateState(structs.TaskStateDead, nil)

// Wait here in case the allocation is restarted. Poststop tasks will never
// run again so, skip them to avoid blocking forever.
// run again so skip them to avoid blocking forever.
if !tr.Task().IsPoststop() {
ALLOC_RESTART:
// Run in a loop to handle cases where restartCh is triggered but the
Expand Down
10 changes: 5 additions & 5 deletions client/allocrunner/taskrunner/task_runner_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -398,7 +398,7 @@ func TestTaskRunner_Restore_Dead(t *testing.T) {
// Retry a few times as the newTR.Run() may not have started yet.
testutil.WaitForResult(func() (bool, error) {
ev := &structs.TaskEvent{Type: structs.TaskRestartSignal}
err = newTR.Rerun(context.Background(), ev, false)
err = newTR.ForceRestart(context.Background(), ev, false)
return err == nil, err
}, func(err error) {
require.NoError(t, err)
Expand Down Expand Up @@ -426,7 +426,7 @@ func TestTaskRunner_Restore_Dead(t *testing.T) {
defer newTR2.Kill(context.Background(), structs.NewTaskEvent("cleanup"))

ev := &structs.TaskEvent{Type: structs.TaskRestartSignal}
err = newTR2.Rerun(context.Background(), ev, false)
err = newTR2.ForceRestart(context.Background(), ev, false)
require.Equal(t, err, ErrTaskNotRunning)
}

Expand Down Expand Up @@ -1386,15 +1386,15 @@ func TestTaskRunner_CheckWatcher_Restart(t *testing.T) {
"Received",
"Task Setup",
"Started",
"Restart Running Signaled",
"Restart Signaled",
"Terminated",
"Restarting",
"Started",
"Restart Running Signaled",
"Restart Signaled",
"Terminated",
"Restarting",
"Started",
"Restart Running Signaled",
"Restart Signaled",
"Terminated",
"Not Restarting",
}
Expand Down
3 changes: 2 additions & 1 deletion website/content/docs/commands/alloc/restart.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ allocation's namespace.
## Restart Options

- `-all-tasks`: If set, all tasks in the allocation will be restarted, even the
ones that already ran. This option cannot be used if a task is defined.
ones that already ran. This option cannot be used with `-task` or the
`<task>` argument.

- `-task`: Specify the individual task to restart. This option cannot be used
with `-all-tasks`.
Expand Down

0 comments on commit 8037a17

Please sign in to comment.