Skip to content

Conversation

@kashifest
Copy link
Member

  • Compare IP addresses by parsed value instead of raw strings to handle non-canonical IPv6 formats (::0005 vs ::5).
  • Also adding regression tests.

Fixes #1244

Checklist:

  • Documentation has been updated, if necessary.
  • Unit tests have been added, if necessary.
  • E2E tests have been added, if necessary.
  • Integration tests have been added, if necessary.

@kashifest kashifest requested a review from Copilot December 18, 2025 12:43
@metal3-io-bot metal3-io-bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Dec 18, 2025
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 fixes a bug where IPv6 addresses in non-canonical format (e.g., 2001:db8::0005) were not correctly matched with their canonical equivalents (e.g., 2001:db8::5) during IPAM pre-allocation processing.

Key Changes:

  • Introduced an ipEqual() helper function that parses and compares IP addresses semantically rather than as strings
  • Updated all IP address comparisons in pre-allocation logic to use ipEqual() instead of string equality
  • Added regression tests for both Metal3 IPClaim and CAPI IPAddressClaim with non-canonical IPv6 pre-allocations

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
ipam/ippool_manager.go Added ipEqual() function and replaced 8 string comparisons with semantic IP equality checks in both allocateAddress() and capiAllocateAddress() functions
ipam/ippool_manager_test.go Added two test cases verifying that non-canonical IPv6 pre-allocations (e.g., ::0005) correctly match and return canonical addresses (e.g., ::5)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Compare IP addresses by parsed value instead of raw strings to handle
non-canonical IPv6 formats (::0005 vs ::5).
- Also adding regression tests.

Signed-off-by: Kashif Khan <[email protected]>
@kashifest
Copy link
Member Author

/test metal3-centos-e2e-integration-test-main metal3-ubuntu-e2e-integration-test-main

@tuminoid
Copy link
Member

tuminoid commented Dec 18, 2025

Whats the relation with #1249 ? Both claim to fix the same issue.

@kashifest
Copy link
Member Author

Whats the relation with #1249 ? Both claim to fix the same issue.

@peppi-lotta is adding validation there, she asked me to push the fix and she will rebase

Copy link
Member

@adilGhaffarDev adilGhaffarDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Dec 18, 2025
@adilGhaffarDev
Copy link
Member

/cherry-pick release-1.11
/cherry-pick release-1.12

@metal3-io-bot
Copy link
Contributor

@adilGhaffarDev: once the present PR merges, I will cherry-pick it on top of release-1.11, release-1.12 in new PRs and assign them to you.

Details

In response to this:

/cherry-pick release-1.11
/cherry-pick release-1.12

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link
Member

@tuminoid tuminoid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/approve

@metal3-io-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: tuminoid

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

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Dec 18, 2025
@metal3-io-bot metal3-io-bot merged commit b5b6a3b into metal3-io:main Dec 18, 2025
15 checks passed
@metal3-io-bot metal3-io-bot deleted the fix/ip-checking branch December 18, 2025 18:52
@metal3-io-bot metal3-io-bot added this to the IPAM - v1.13 milestone Dec 18, 2025
@metal3-io-bot
Copy link
Contributor

@adilGhaffarDev: new pull request created: #1251

Details

In response to this:

/cherry-pick release-1.11
/cherry-pick release-1.12

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@metal3-io-bot
Copy link
Contributor

@adilGhaffarDev: new pull request created: #1252

Details

In response to this:

/cherry-pick release-1.11
/cherry-pick release-1.12

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

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. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

IPv6 preAllocations are rejected due to leading zeros triggering “Pre-allocated IP out of bond”.

4 participants