-
Notifications
You must be signed in to change notification settings - Fork 10
Make leader election ID and election namespace optional. #53
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
Make leader election ID and election namespace optional. #53
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR makes the leader election ID and namespace optional by introducing new environment variables and implementing fallback logic to maintain backward compatibility with existing deployments.
- Introduces
IPAM_LEADER_ELECT_IDandIPAM_LEADER_ELECT_NAMESPACEenvironment variables for optional configuration - Adds fallback logic that checks new variables first, then legacy
POD_NAME/POD_NAMESPACE, and finally uses hostname/default namespace - Refactors the leader election configuration structure and function signatures to consolidate parameters
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| pkg/leaderelection/leaderelection.go | Adds new config fields, implements fallback logic for lock ID/namespace, and refactors function signatures |
| main.go | Consolidates leader election config into a nested struct and updates function calls |
| README.md | Documents the new optional environment variables |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
one just final comment and LGTM |
|
/lgtm Thanks for your hard work |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: aojea, mneverov 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 |
|
@mneverov the bot complains because there is an invalid commit, so maybe you squash and merge now that is all reviewed? |
4f09a3c to
79f9a1b
Compare
|
/lgtm I totally forget about this sorry |
|
it is better if you ping me directly, github notifications are easy to miss |
The main change is: introduced two new environment variables and added them to readme.
The lock ID and lock namespace are calculated now:
POD_NAMEandPOD_NAMESPACEso the legacy behavior is the samenodeutil.GetHostnameand default namespace if none above. This allows to have the optional env. variables.In retrospect it was a bad decision - should have hardcoded lock ID to smth like
node-ipam-controller.k8s.ioand use the default namespace as noone ever overrides these.Fixes #39