Skip to content

Commit faecdc7

Browse files
committed
Only cancel leader election if the runnables have shutdown
Signed-off-by: Vince Prignano <[email protected]>
1 parent fa1ed34 commit faecdc7

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

pkg/manager/internal.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -549,10 +549,10 @@ func (cm *controllerManager) engageStopProcedure(stopComplete <-chan struct{}) e
549549

550550
// waitForRunnableToEnd blocks until all runnables ended or the
551551
// tearDownTimeout was reached. In the latter case, an error is returned.
552-
func (cm *controllerManager) waitForRunnableToEnd(shutdownCancel context.CancelFunc) error {
552+
func (cm *controllerManager) waitForRunnableToEnd(shutdownCancel context.CancelFunc) (retErr error) {
553553
// Cancel leader election only after we waited. It will os.Exit() the app for safety.
554554
defer func() {
555-
if cm.leaderElectionCancel != nil {
555+
if retErr == nil && cm.leaderElectionCancel != nil {
556556
// After asking the context to be cancelled, make sure
557557
// we wait for the leader stopped channel to be closed, otherwise
558558
// we might encounter race conditions between this code

0 commit comments

Comments
 (0)