-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing cancellation support in LeaderElector
#2207
Comments
In your example you can achieve this in a "not so clean" way by killing the thread that is running the LeaderElector loop, exception handling in LeaderElector should take care of cleaning up local resources, cluster should get outdated in the provided period, so a new leader would take its place (this is demonstrated in this example). However, adding a cleaner way to stop the LeaderElector could be easily added, we should definitely consider it. |
Hi there, I guess by "killing the thread" you mean I should set its interrupted flag, right? I did that by calling |
Yes if it's the same Java application (as our provided example). But there could be several instances of the same application running (so it would mean killing the leader application). Or maybe several Pods running (so it would mean deleting the Pod). I don't know what happened in you example, but basically this is what's implemented in the provided example (which kills the thread which acquired the lock every 2.5 seconds): Lines 140 to 158 in d3d6594
You can check out the example by running Anyway, adding the cancel method is something to be considered. |
This issue has been automatically marked as stale because it has not had any activity since 90 days. It will be closed if no further activity occurs within 7 days. Thank you for your contributions! |
…and easy cancel also removing holding a thread when using start and adding more jitter support
…and easy cancel also removing holding a thread when using start and adding more jitter support
…and easy cancel also removing holding a thread when using start and adding more jitter support
…and easy cancel also removing holding a thread when using start and adding more jitter support
…and easy cancel also removing holding a thread when using start and adding more jitter support
…and easy cancel also removing holding a thread when using start and adding more jitter support
…and easy cancel also removing holding a thread when using start and adding more jitter support
…and easy cancel also removing holding a thread when using start and adding more jitter support
…and easy cancel also removing holding a thread when using start and adding more jitter support and a cleanup of the retry logic
…and easy cancel also removing holding a thread when using start and adding more jitter support and a cleanup of the retry logic
…and easy cancel also removing holding a thread when using start and adding more jitter support and a cleanup of the retry logic
also removing holding a thread when using start and adding more jitter support and a cleanup of the retry logic
After calling run() on the leader it will eventually enter the loop for renewing its lease.
There does not seem to be an API for gracefully shutting down a leader elector. I imagine that there should be a way to make the LeaderElector break out of the renewal loop, e.g. calling cancel() on a leader elector.
Following code does not cancel the leader elector
Note: the original kubernetes Java client has a similar issue, see kubernetes-client/java#944
Relates to
The text was updated successfully, but these errors were encountered: