Skip to content
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

🐛 Controller does not allocate reserved addresses #171

Merged

Conversation

adobley
Copy link
Contributor

@adobley adobley commented Jul 7, 2023

What this PR does / why we need it:
The validation code continues to accept pools that contain the network (the first address in the inferred subnet) and broadcast (the last address in the inferred subnet) addresses, but the controller will not allocate these addresses. When the pool is configured with IPv6, the anycast address (the first address in the inferred subnet) will not be allocated.

This PR also refactors the claim reconciler. Previously, the controller would continue to reconcile (and ultimately no-op) despite the pool not being found. The new spec flag,AllocateReservedIPAddresses exposed this oddness, prompting some refactoring.

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

@adobley adobley requested a review from schrej as a code owner July 7, 2023 18:04
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jul 7, 2023
@k8s-ci-robot k8s-ci-robot requested a review from srm09 July 7, 2023 18:04
@k8s-ci-robot k8s-ci-robot added the size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. label Jul 7, 2023
if gateway != "" {
addrStrings = append(addrStrings, gateway)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

We no longer consider the gateway in use, but with this change set the gateway is not in available list.

Entry("When the addresses range includes network addr, it is not available - InClusterIPPool",
"InClusterIPPool", 24, []string{"10.0.0.0-10.0.0.1"}, "10.0.0.2", 1, 1, 0),
Entry("When the addresses range includes broadcast, it is not available - InClusterIPPool",
"InClusterIPPool", 24, []string{"10.0.0.254-10.0.0.255"}, "10.0.0.1", 1, 1, 0),
Copy link
Contributor

Choose a reason for hiding this comment

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

When a reserved address is in the Spec.Addresses, it is not considered used, nor free.

@tylerschultz
Copy link
Contributor

Once again, I worked on this commit, so I should recuse. FWIW, LGTM. @adobley and I re-reviewed it after some time away and we think it's good to go.

@flawedmatrix flawedmatrix force-pushed the reserve-network-broadcast-addrs branch from 7295e55 to a5939b1 Compare July 24, 2023 17:19
@adobley
Copy link
Contributor Author

adobley commented Jul 24, 2023

Fixed a misspelling, should be good to go.

@k8s-ci-robot k8s-ci-robot added cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. and removed cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Jul 26, 2023
@schrej
Copy link
Member

schrej commented Jul 28, 2023

lgtm, but the linter is complaining about one spelling mistake.
Can you check why CLA is unhappy?

Sorry that it took so long, a lot going on.

@flawedmatrix flawedmatrix force-pushed the reserve-network-broadcast-addrs branch from a5939b1 to f74b3eb Compare August 1, 2023 23:48
@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. and removed cncf-cla: no Indicates the PR's author has not signed the CNCF CLA. labels Aug 1, 2023
@adobley
Copy link
Contributor Author

adobley commented Aug 1, 2023

Fixed the typo and the CLA fixed itself. Strange.

unless `pool.Spec.AllocateReservedIPAddresses` is true.

The validation code continues to accept pools that contain the network
(the first address in the inferred subnet) and broadcast (the
last address in the inferred subnet) addresses, but the controller will
not allocate these addresses. When the pool is configured with IPv6, the
anycast address (the first address in the inferred subnet) will not be
allocated.

This commit also refactors the claim reconciler. Previously, the
controller would continue to reconcile (and ultimately no-op) despite
the pool not being found. The new spec flag,
`AllocateReservedIPAddresses` exposed this oddness, prompting some
refactoring.

Co-authored-by: Aidan Obley <[email protected]>
Co-authored-by: Edwin Xie <[email protected]>
@adobley adobley force-pushed the reserve-network-broadcast-addrs branch from f74b3eb to 96dbef6 Compare August 2, 2023 17:24
@schrej
Copy link
Member

schrej commented Aug 6, 2023

/lgtm
/approve

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

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: adobley, 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 Aug 6, 2023
@k8s-ci-robot k8s-ci-robot merged commit 678b6c0 into kubernetes-sigs:main Aug 6, 2023
@adobley adobley deleted the reserve-network-broadcast-addrs branch August 7, 2023 17:30
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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Controller shouldn't allocate IP addresses that are "reserved" for the subnet
4 participants