Skip to content

Conversation

@mneverov
Copy link
Member

@mneverov mneverov commented Sep 19, 2025

The main change is: introduced two new environment variables and added them to readme.
The lock ID and lock namespace are calculated now:

  1. check new variables
  2. check previously used variables POD_NAME and POD_NAMESPACE so the legacy behavior is the same
  3. Use nodeutil.GetHostname and 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.io and use the default namespace as noone ever overrides these.

Fixes #39

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 19, 2025
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 19, 2025
@aojea aojea marked this pull request as ready for review September 20, 2025 07:48
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 20, 2025
@aojea aojea requested a review from Copilot October 6, 2025 09:42
Copy link

Copilot AI left a 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_ID and IPAM_LEADER_ELECT_NAMESPACE environment 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.

@k8s-ci-robot k8s-ci-robot added the do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. label Oct 8, 2025
@aojea
Copy link
Contributor

aojea commented Oct 8, 2025

one just final comment and LGTM

@aojea
Copy link
Contributor

aojea commented Oct 9, 2025

/lgtm
/approve

Thanks for your hard work

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 9, 2025
@k8s-ci-robot
Copy link
Contributor

[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

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@aojea
Copy link
Contributor

aojea commented Oct 9, 2025

@mneverov the bot complains because there is an invalid commit, so maybe you squash and merge now that is all reviewed?

@mneverov mneverov force-pushed the optional-name-namespace branch from 4f09a3c to 79f9a1b Compare October 9, 2025 16:43
@k8s-ci-robot k8s-ci-robot removed lgtm "Looks good to me", indicates that a PR is ready to be merged. do-not-merge/invalid-commit-message Indicates that a PR should not merge because it has an invalid commit message. labels Oct 9, 2025
@mneverov mneverov requested a review from aojea November 6, 2025 11:31
@aojea
Copy link
Contributor

aojea commented Dec 18, 2025

/lgtm

I totally forget about this sorry

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 18, 2025
@aojea
Copy link
Contributor

aojea commented Dec 18, 2025

it is better if you ping me directly, github notifications are easy to miss

@k8s-ci-robot k8s-ci-robot merged commit cc6c61f into kubernetes-sigs:main Dec 18, 2025
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make pod_name and pod_namespace optional

3 participants