Skip to content

✨ Allow address exclusion #182

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

Merged
merged 6 commits into from
Sep 15, 2023

Conversation

Noroth
Copy link
Contributor

@Noroth Noroth commented Aug 22, 2023

What this PR does / why we need it:
Currently, the only way to exclude certain IP addresses is to specify multiple ranges inside the addresses field in the InClusterIPPoolSpec.

To enhance this, a new optional field will be added, where another list of IP addresses can be provided. These will be excluded during the allocation of new IP addresses.

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 #180

@Noroth Noroth requested a review from schrej as a code owner August 22, 2023 18:22
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 22, 2023
@k8s-ci-robot k8s-ci-robot requested a review from srm09 August 22, 2023 18:22
@k8s-ci-robot
Copy link
Contributor

Welcome @Noroth!

It looks like this is your first PR to kubernetes-sigs/cluster-api-ipam-provider-in-cluster 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/cluster-api-ipam-provider-in-cluster has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 22, 2023
Copy link
Member

@schrej schrej left a comment

Choose a reason for hiding this comment

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

One minor thing, looks good apart from that. Tests are failing and the linter is unhappy, could you take a look?

Comment on lines 221 to 227
from := ipSet.Ranges()[0].From()
hasIPv4Addr = hasIPv4Addr || from.Is4()
hasIPv6Addr = hasIPv6Addr || from.Is6()
}

if hasIPv4Addr && hasIPv6Addr {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec", "excludedAddresses"), newPool.PoolSpec().ExcludedAddresses, "provided addresses are of mixed IP families"))
Copy link
Member

Choose a reason for hiding this comment

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

We need to make sure that the family of excludedAddresses matches the family of addresses, and not that the family is the same for all. This approach should work, but it would be good to be a bit more explicit about it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No problem, will add an additional check.

I initially thought that it wouldn't really matter as we are creating a set of IPs from the provided addresses and then just removing whatever is being found in the excluded addresses. Therefore if you attempt to remove ipv6 addresses from ipv4 addresses and vice versa, nothing will happen.

@Noroth
Copy link
Contributor Author

Noroth commented Aug 29, 2023

Seems like a test timed out. I tried to reproduce it locally but tests are never failing for me

@Noroth
Copy link
Contributor Author

Noroth commented Aug 29, 2023

/test all

@k8s-ci-robot
Copy link
Contributor

@Noroth: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/test all

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/test-infra repository.

@Noroth Noroth changed the title Allow address exclusion ✨ Allow address exclusion Aug 30, 2023
@Noroth
Copy link
Contributor Author

Noroth commented Sep 15, 2023

/cc @schrej

I'm ready, could you please take another look?

@k8s-ci-robot k8s-ci-robot requested a review from schrej September 15, 2023 06:38
Copy link
Member

@schrej schrej left a comment

Choose a reason for hiding this comment

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

/lgtm

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Noroth, schrej

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

The pull request process is described 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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 15, 2023
@k8s-ci-robot k8s-ci-robot merged commit 718c702 into kubernetes-sigs:main Sep 15, 2023
@schrej
Copy link
Member

schrej commented Sep 19, 2023

And thank you, by the way! 🎉

@Noroth
Copy link
Contributor Author

Noroth commented Sep 23, 2023

No problem, happy to contribute. Was always looking for a task that I could work on in the k8s environment 😁

@Noroth Noroth deleted the allow-address-exclusion branch September 27, 2023 15:14
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.

Handle reserved Ips withing an IP range
3 participants