Skip to content

Commit

Permalink
services: un-mark group services as deregistered if restart hook runs
Browse files Browse the repository at this point in the history
This PR may fix a bug where group services will never be deregistered if the
group undergoes a task restart.
  • Loading branch information
shoenig committed Apr 24, 2023
1 parent b4e6a70 commit af11145
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions client/allocrunner/group_service_hook.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,14 @@ func (h *groupServiceHook) Prerun() error {
defer func() {
// Mark prerun as true to unblock Updates
h.prerun = true
// Mark deregistered as false to allow de-registration
h.deregistered = false
h.mu.Unlock()
}()
return h.preRunLocked()
}

// caller must hold h.lock
// caller must hold h.mu
func (h *groupServiceHook) preRunLocked() error {
if len(h.services) == 0 {
return nil
Expand Down Expand Up @@ -188,6 +190,8 @@ func (h *groupServiceHook) PreTaskRestart() error {
defer func() {
// Mark prerun as true to unblock Updates
h.prerun = true
// Mark deregistered as false to allow de-registration
h.deregistered = false
h.mu.Unlock()
}()

Expand All @@ -201,7 +205,7 @@ func (h *groupServiceHook) PreKill() {

// implements the PreKill hook
//
// caller must hold h.lock
// caller must hold h.mu
func (h *groupServiceHook) preKillLocked() {
// If we have a shutdown delay deregister group services and then wait
// before continuing to kill tasks.
Expand Down

0 comments on commit af11145

Please sign in to comment.