Skip to content

Conversation

rikatz
Copy link
Member

@rikatz rikatz commented Jun 5, 2025

What this PR does / why we need it:
IPAM controller relies on controller runtime client, which is cached, to list the existing address before allocating a new IP.

When the cache is too slow to reflect the changes, we may end up with an IPAddressClaim reconciliation happening before the previous reconciliation address acknowledge by the cache, which may end with duplicated IP address allocations.

This change enforces that the Reconcile function waits for the cached client to be aware of the IPAddress before allowing the reconciliation to move on to the next reconciliation request

Previous art for a similar problem: https://github.com/kubernetes-sigs/cluster-api/blob/fefd5ac02f9b1497b34ae286108560328e16deef/internal/controllers/topology/cluster/reconcile_state.go#L654

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 #

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jun 5, 2025
@k8s-ci-robot k8s-ci-robot requested review from mcbenjemaa and srm09 June 5, 2025 12:57
@k8s-ci-robot k8s-ci-robot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jun 5, 2025
@rikatz rikatz force-pushed the check-cached-client-before-moving branch from 7f4339b to 9cf17a9 Compare June 5, 2025 13:13
@rikatz
Copy link
Member Author

rikatz commented Jun 5, 2025

/cc @schrej

@k8s-ci-robot k8s-ci-robot requested a review from schrej June 5, 2025 14:19
@rikatz
Copy link
Member Author

rikatz commented Jun 5, 2025

/kind bug

@k8s-ci-robot k8s-ci-robot added the kind/bug Categorizes issue or PR as related to a bug. label Jun 5, 2025
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.

good find, just one nit.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 5, 2025
IPAM controller relies on controller runtime client, which is cached, to
list the existing address before allocating a new IP.

When the cache is too slow to reflect the changes, we may end up with an
IPAddressClaim reconciliation happening before the previous reconciliation
address acknowledge by the cache, which may end with duplicated IP address
allocations.

This change enforces that the Reconcile function waits for the cached client
to be aware of the IPAddress before allowing the reconciliation to move on
to the next reconciliation request
@rikatz rikatz force-pushed the check-cached-client-before-moving branch from 9cf17a9 to 404c2e7 Compare June 5, 2025 14:26
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Jun 5, 2025
@rikatz
Copy link
Member Author

rikatz commented Jun 5, 2025

good find, just one nit.

yeah, don't ask me how I was able to find it (spoiler alert: a very slow environment :P )

@schrej
Copy link
Member

schrej commented Jun 5, 2025

/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 Jun 5, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 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 Jun 5, 2025
@k8s-ci-robot k8s-ci-robot merged commit 4987282 into kubernetes-sigs:main Jun 5, 2025
5 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. kind/bug Categorizes issue or PR as related to a bug. lgtm "Looks good to me", indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants