Skip to content

Provide a leader election module #297

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

Closed
multani opened this issue Jan 8, 2024 · 1 comment · Fixed by #347
Closed

Provide a leader election module #297

multani opened this issue Jan 8, 2024 · 1 comment · Fixed by #347
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@multani
Copy link
Contributor

multani commented Jan 8, 2024

It would be great if the library could provide an out of the box module to implement leader election.

The sync library has an implementation in https://github.com/kubernetes-client/python/blob/master/kubernetes/base/leaderelection/

Is it something that the asyncio library could provide?

@tomplus
Copy link
Owner

tomplus commented Jan 10, 2024

Thanks for spotting this, this library should provide this feature.

@tomplus tomplus added enhancement New feature or request help wanted Extra attention is needed labels Jan 10, 2024
JacobHenner added a commit to JacobHenner/kubernetes_asyncio that referenced this issue Jan 5, 2025
Add leaderelection module, based off of the leaderelection module in
kubernetes-client/python. The module has been altered slightly to
support asyncio.

Fixes tomplus#297
JacobHenner added a commit to JacobHenner/kubernetes_asyncio that referenced this issue Jan 5, 2025
Add leaderelection module, based off of the leaderelection module in
kubernetes-client/python. The module has been altered slightly to
support asyncio.

Fixes tomplus#297
JacobHenner added a commit to JacobHenner/kubernetes_asyncio that referenced this issue Jan 6, 2025
Add leaderelection module, based off of the leaderelection module in
kubernetes-client/python. The module has been altered slightly to
support asyncio.

Fixes tomplus#297
JacobHenner added a commit to JacobHenner/kubernetes_asyncio that referenced this issue Jan 6, 2025
Add leaderelection module, based off of the leaderelection module in
kubernetes-client/python. The module has been altered slightly to
support asyncio.

Fixes tomplus#297
tomplus pushed a commit that referenced this issue Mar 30, 2025
* Add leaderelection module

Add leaderelection module, based off of the leaderelection module in
kubernetes-client/python. The module has been altered slightly to
support asyncio.

Fixes #297

* Add leaselock

Add leaselock, derived from [1].

[1]: https://github.com/kubernetes-client/python/pull/2314/files

* Switch callbacks to coroutines

Instead of passing Callable[...,Coroutine] functions as callbacks, pass
Coroutines directly. This allows the caller to supply arbitrary context
associated with the Coroutine, such as the ApiClient used to establish
the leader election.

* Logging fixes

* Remove misplaced basicConfig
* Use %-style string interpolation

* Revise log levels

* Accept both coroutines and coroutine functions
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants