diff --git a/pkg/manager/internal.go b/pkg/manager/internal.go index a16f354a1b..fdb9d982d9 100644 --- a/pkg/manager/internal.go +++ b/pkg/manager/internal.go @@ -518,6 +518,8 @@ func (cm *controllerManager) engageStopProcedure(stopComplete <-chan struct{}) e // Stop all the leader election runnables, which includes reconcilers. cm.logger.Info("Stopping and waiting for leader election runnables") + // Prevent leader election when shutting down a non-elected manager + cm.runnables.LeaderElection.startOnce.Do(func() {}) cm.runnables.LeaderElection.StopAndWait(cm.shutdownCtx) // Stop the caches before the leader election runnables, this is an important diff --git a/pkg/manager/manager_test.go b/pkg/manager/manager_test.go index a88ccca00f..7a07308403 100644 --- a/pkg/manager/manager_test.go +++ b/pkg/manager/manager_test.go @@ -1227,6 +1227,10 @@ var _ = Describe("manger.Manager", func() { cm.onStoppedLeading = func() {} }, ) + + It("should not start a new leader election", func() { + + }) }) Context("should start serving metrics", func() {