From af1114552ed05563012abac608d65e817316e707 Mon Sep 17 00:00:00 2001 From: Seth Hoenig Date: Mon, 17 Apr 2023 12:02:12 -0500 Subject: [PATCH] services: un-mark group services as deregistered if restart hook runs This PR may fix a bug where group services will never be deregistered if the group undergoes a task restart. --- client/allocrunner/group_service_hook.go | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/client/allocrunner/group_service_hook.go b/client/allocrunner/group_service_hook.go index 30a698ecdfc..a63f6f60762 100644 --- a/client/allocrunner/group_service_hook.go +++ b/client/allocrunner/group_service_hook.go @@ -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 @@ -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() }() @@ -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.