🐛 manager: suppress expected leader-election-lost error on graceful shutdown#3536
🐛 manager: suppress expected leader-election-lost error on graceful shutdown#3536liketosweep wants to merge 2 commits into
Conversation
|
Welcome @liketosweep! |
|
Hi @liketosweep. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Regular contributors should join the org to skip this step. Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: liketosweep The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Signed-off-by: liketosweep <liketosweep@gmail.com>
Fixes #3535
What the Issue Was
On graceful shutdown with
LeaderElectionenabled, cancelling theleader election context triggers
OnStoppedLeading, which pusheserrLeaderElectionLostontoerrChan. The drain goroutine inengageStopProcedureonly filteredcontext.Canceled, so thisexpected error was logged as unexpected:
When combined with
t.Output()in tests, this also causes panics ordata races as the manager writes to the test log after the test exits.
Solution
errLeaderElectionLostsentinel for reliableerrors.Ismatching.OnStoppedLeadinginstead of an anonymouserrors.New.engageStopProceduredrain filteralongside
context.Canceled.Genuine mid-run leader election loss (before stop is engaged) still
propagates to
Start's caller unchanged.Changes
pkg/manager/internal.go: sentinel + filter fix.pkg/manager/manager_test.go: regression test for graceful shutdown.Testing