Skip to content

Commit 8037a17

Browse files
committed
minor fixes
1 parent e620cd1 commit 8037a17

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

client/allocrunner/taskrunner/task_runner.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -518,10 +518,10 @@ func (tr *TaskRunner) Run() {
518518
runComplete := tr.localState.RunComplete
519519
tr.stateLock.RUnlock()
520520

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

688688
// Wait here in case the allocation is restarted. Poststop tasks will never
689-
// run again so, skip them to avoid blocking forever.
689+
// run again so skip them to avoid blocking forever.
690690
if !tr.Task().IsPoststop() {
691691
ALLOC_RESTART:
692692
// Run in a loop to handle cases where restartCh is triggered but the

client/allocrunner/taskrunner/task_runner_test.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ func TestTaskRunner_Restore_Dead(t *testing.T) {
398398
// Retry a few times as the newTR.Run() may not have started yet.
399399
testutil.WaitForResult(func() (bool, error) {
400400
ev := &structs.TaskEvent{Type: structs.TaskRestartSignal}
401-
err = newTR.Rerun(context.Background(), ev, false)
401+
err = newTR.ForceRestart(context.Background(), ev, false)
402402
return err == nil, err
403403
}, func(err error) {
404404
require.NoError(t, err)
@@ -426,7 +426,7 @@ func TestTaskRunner_Restore_Dead(t *testing.T) {
426426
defer newTR2.Kill(context.Background(), structs.NewTaskEvent("cleanup"))
427427

428428
ev := &structs.TaskEvent{Type: structs.TaskRestartSignal}
429-
err = newTR2.Rerun(context.Background(), ev, false)
429+
err = newTR2.ForceRestart(context.Background(), ev, false)
430430
require.Equal(t, err, ErrTaskNotRunning)
431431
}
432432

@@ -1386,15 +1386,15 @@ func TestTaskRunner_CheckWatcher_Restart(t *testing.T) {
13861386
"Received",
13871387
"Task Setup",
13881388
"Started",
1389-
"Restart Running Signaled",
1389+
"Restart Signaled",
13901390
"Terminated",
13911391
"Restarting",
13921392
"Started",
1393-
"Restart Running Signaled",
1393+
"Restart Signaled",
13941394
"Terminated",
13951395
"Restarting",
13961396
"Started",
1397-
"Restart Running Signaled",
1397+
"Restart Signaled",
13981398
"Terminated",
13991399
"Not Restarting",
14001400
}

website/content/docs/commands/alloc/restart.mdx

+2-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,8 @@ allocation's namespace.
3939
## Restart Options
4040

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

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

0 commit comments

Comments
 (0)