Skip to content

Commit

Permalink
馃悰 prevent leader election when shutting down a non-elected manager
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandremahdhaoui committed Mar 23, 2024
1 parent e08b286 commit 4ef9863
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
2 changes: 2 additions & 0 deletions pkg/manager/internal.go
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions pkg/manager/manager_test.go
Expand Up @@ -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() {
Expand Down

0 comments on commit 4ef9863

Please sign in to comment.