You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
The doc string for the LeaderElector's run() method state:
stopLeadingHook called when a LeaderElector client stops leading
However, stopLeadingHook is called both when the client stops leading and when an exception causes the client to exit the acquire loop. In our particular case, the thread executing the acquire loop experienced an InterruptedException which caused this. I think either the docs should be updated to reflect that the hook is called in such cases or the code should be updated to only run the hook when leadership was actually acquired.
From the caller's perspective, I think the latter probably makes more sense. I'd be happy to submit a PR.
Client Version
Present on current tip of master, a86df3a753af9c616f40c18b37ac6ef86921ece9
Kubernetes Version
1.26
Java Version
Java 17
To Reproduce
Steps to reproduce the behavior:
Pass any stopLeadingHook to the LeaderElector's run() method.
Cause the acquire loop to throw an exception.
Observe the stop leading hook being executed.
Expected behavior
Based on the doc string of the method, I expected the 'stopLeadingHook' to only be executed in cases where the client had actually acquired leadership and its leadership ended.
Server (please complete the following information):
OS: Linux
Environment: EC2 VM
Cloud: AWS
The text was updated successfully, but these errors were encountered:
Describe the bug
The doc string for the LeaderElector's
run()
method state:However,
stopLeadingHook
is called both when the client stops leading and when an exception causes the client to exit the acquire loop. In our particular case, the thread executing the acquire loop experienced anInterruptedException
which caused this. I think either the docs should be updated to reflect that the hook is called in such cases or the code should be updated to only run the hook when leadership was actually acquired.From the caller's perspective, I think the latter probably makes more sense. I'd be happy to submit a PR.
Client Version
Present on current tip of master,
a86df3a753af9c616f40c18b37ac6ef86921ece9
Kubernetes Version
1.26
Java Version
Java 17
To Reproduce
Steps to reproduce the behavior:
stopLeadingHook
to the LeaderElector'srun()
method.Expected behavior
Based on the doc string of the method, I expected the 'stopLeadingHook' to only be executed in cases where the client had actually acquired leadership and its leadership ended.
Server (please complete the following information):
The text was updated successfully, but these errors were encountered: