Repository navigation
🌱 Skip graceful shutdown if lease is lost during shutdown - #3651
sbueringer wants to merge 1 commit into
Conversation
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: sbueringer The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/hold /assign @alvaroaleman |
| // NOTE: This must be closed at most once. That holds because we call Run only once | ||
| // and don't set LeaderElectionConfig.Recovery: with Recovery, client-go can call | ||
| // OnStoppedLeading multiple times per Run, which would panic here on a double close. |
There was a problem hiding this comment.
This is the explanation why closing the channel below is not in a sync.Once. I'm fine either dropping the comment or with dropping the comment and using a sync.Once just to be safe
| // It can be overridden for tests. | ||
| onStoppedLeading func() | ||
|
|
||
| // shutdownCtx is the context that can be used during shutdown. It will be cancelled |
There was a problem hiding this comment.
There is no reason (anymore, also before this PR) why this has to be a field on the struct instead of just a local variable, so I changed that to simplify
3feadbe to
b98b9d2
Compare
alvaroaleman
left a comment
There was a problem hiding this comment.
Have to look deeper but don't we cancel the leader lease ctx during shutdown and thus will always run into this case?
(I'll flip the order in that select just in case it makes it more robust that we hit the shutdownCtx.Done() branch, not sure if it makes a difference) |
b98b9d2 to
3407d15
Compare
I think we want a manager to shutdown as quickly as possible if we lose the leader lease.
What already worked is that if the manager is running and we lose the leader lease we ~ skip the graceful shutdown.
What didn't work is that if we were already shutting down gracefully losing the leader lease during that did not cancel the ongoing graceful shutdown.