Skip to content

✨ Adding feature for allocating requested IP #997

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ksahil12
Copy link

What this PR does / why we need it:
Requirement: Allocate a specific to IPAddressClaim or IPClaim when created with special label.
Solution: During creation of IPAddressClaim, user can provide a special label i.e. ipAddress: <IP_TO_BE_REQUESTED>. Once IPAddressClaim goes for allocation logic in ip_pool_manager, we can handle the allocation of this IP based on the requestedIP and available IPs.
For a happy path scenario, when allocation is successful, we will create IPAddress with the same IP and update IPPool index with the allocated IP.
For a scenario where user has requested an IP which does not belong to range or not available, we can patch IPAddressClaim CR with the error mentioning the same.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #969

@metal3-io-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign tuminoid for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 10, 2025
@metal3-io-bot
Copy link
Contributor

Hi @ksahil12. Thanks for your PR.

I'm waiting for a metal3-io member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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 metal3-io-bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Apr 10, 2025
@tuminoid tuminoid added this to the IPAM - v1.11 milestone Apr 10, 2025
@tuminoid
Copy link
Member

/ok-to-test
/cc @kashifest @peppi-lotta @adilGhaffarDev

@metal3-io-bot metal3-io-bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 10, 2025
@peppi-lotta
Copy link
Member

I tested a situation where pools preAllocations are:

Pre Allocations:
  test1:  192.168.0.12
  test2:  192.168.0.15
  test3:  192.168.0.17

and I the applied an IPClaim:

apiVersion: ipam.metal3.io/v1alpha1
kind: IPClaim
metadata:
  name: test2
  namespace: default
  labels:
    ipAddress: 192.168.0.20
spec:
  pool:
    name: pool1
    namespace: default

IpClaim then has error Error Message: Requested IP not available, which is not true. Could you add something like "PreAllocation and requested ip address are conflicting" or something along those lines.

Otherwise the feature seems to be working as I expected.

@peppi-lotta
Copy link
Member

peppi-lotta commented Apr 11, 2025

Could you also add tests for situation
One pool, with start and existing address, ipAddress label present and requested ipAddress in preAllocations with conflicting ipclaim name

One pool, with start and existing address, ipAddress label present and requested ipAddress in preAllocations with non-conflicting ipclaim name

It is important to understand how the new feature works with preAllocations as those are curretly an important part of CAPM3 upgrading.

@ksahil12
Copy link
Author

Thanks for suggestion @peppi-lotta.
Updated the scenario. Also added test cases.

@peppi-lotta
Copy link
Member

Please rebase your commits into one :)

@ksahil12 ksahil12 force-pushed the feature-allocate-IP branch from e6a046b to abd222a Compare April 11, 2025 12:29
@ksahil12
Copy link
Author

@peppi-lotta updated the PR.

@peppi-lotta
Copy link
Member

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

@peppi-lotta
Copy link
Member

/lgtm
This seems to work well and as expected. Good job and thank you for contributing!

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 15, 2025
@ksahil12
Copy link
Author

@peppi-lotta thanks for the review.
@tuminoid can you help with approvals as it's mentioned above to assign PR to you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lgtm Indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. 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.

Allocating a specific IP from IpClaim
5 participants