cli: job restart command (#16278)

Implement the new `nomad job restart` command that allows operators to
restart allocations tasks or reschedule then entire allocation.

Restarts can be batched to target multiple allocations in parallel.
Between each batch the command can stop and hold for a predefined time
or until the user confirms that the process should proceed.

This implements the "Stateless Restarts" alternative from the original
RFC
(https://gist.github.com/schmichael/e0b8b2ec1eb146301175fd87ddd46180).
The original concept is still worth implementing, as it allows this
functionality to be exposed over an API that can be consumed by the
Nomad UI and other clients. But the implementation turned out to be more
complex than we initially expected so we thought it would be better to
release a stateless CLI-based implementation first to gather feedback
and validate the restart behaviour.

Co-authored-by: Shishir Mahajan <smahajan@roblox.com>
This commit is contained in:
Luiz Aoqui
2023-03-23 18:28:26 -04:00
committed by GitHub
parent 1061ddd0b0
commit fffdbdff06
10 changed files with 3119 additions and 5 deletions

View File

@@ -976,6 +976,12 @@ func (t *Task) SetLogConfig(l *LogConfig) *Task {
return t
}
// SetLifecycle is used to set lifecycle config to a task.
func (t *Task) SetLifecycle(l *TaskLifecycle) *Task {
t.Lifecycle = l
return t
}
// TaskState tracks the current state of a task and events that caused state
// transitions.
type TaskState struct {