Skip to content

Commit

Permalink
client: ignore restart issued to terminal allocations
Browse files Browse the repository at this point in the history
This PR fixes a bug where issuing a restart to a terminal allocation
would cause the allocation to run its hooks anyway. This was particularly
apparent with group_service_hook who would then register services but
then never deregister them - as the allocation would be effectively in
a "zombie" state where it is prepped to run tasks but never will.

Fixes #17079
Fixes #16238
Fixes #14618
  • Loading branch information
shoenig committed May 12, 2023
1 parent ca00af7 commit bd020b4
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions client/allocrunner/alloc_runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -1279,6 +1279,12 @@ func (ar *allocRunner) RestartAll(event *structs.TaskEvent) error {

// restartTasks restarts all task runners concurrently.
func (ar *allocRunner) restartTasks(ctx context.Context, event *structs.TaskEvent, failure bool, force bool) error {

// ensure we are not trying to restart an alloc that is terminal
if !ar.shouldRun() {
return fmt.Errorf("restart of an alloc that should not run")
}

waitCh := make(chan struct{})
var err *multierror.Error
var errMutex sync.Mutex
Expand Down

0 comments on commit bd020b4

Please sign in to comment.