Skip to content

lbipam: widening CIDR range or updating selector of CiliumLoadBalancerIPPool does no longer reassign IPs #41122

Merged
joamaki merged 2 commits intomainfrom
pr/marseel/improve_lbipam
Aug 14, 2025
Merged

lbipam: widening CIDR range or updating selector of CiliumLoadBalancerIPPool does no longer reassign IPs #41122
joamaki merged 2 commits intomainfrom
pr/marseel/improve_lbipam

Conversation

@marseel
Copy link
Copy Markdown
Member

@marseel marseel commented Aug 13, 2025

Previously, whenever CIDR range was extended, we removed all allocations from existing ranges, created new ranges and tried reassigning IPs to new ranges. We've already tried to reuse the same IP, however as we tried first to assign IPs to "unsatisfied" services, they could steal existing IPs from other service, resulting in reallocation of IP for already "satisfied" service, while also resulting in temporary state with two different services having the same IP.

Note that this do not solve a case when CIDR range shrinks. In case of CIDR shrinking, IPs that would still be valid within a new range might get reallocated.

Related: #40358

lbipam: widening CIDR range or updating selector of CiliumLoadBalancerIPPool does no longer reassign IPs 

Previously, whenever CIDR range was extended, we removed all allocations
from existing ranges, created new ranges and tried reassigning IPs to
new ranges. We've already tried to reuse the same IP, however as we
tried first to assign IPs to "unsatisfied" services, they could steal
existing IPs from other service, resulting in reallocation of IP for already
"satisfied" service, while also resulting in temporary state with two
different services having the same IP.

The same issue could have happened, when selector of pool was modified
selecting new unsatisfied services.

Note that this do not solve a case when CIDR range shrinks. In case of
CIDR shrinking, IPs that would still be valid within a new range might
get reallocated.

Related: #40358

Signed-off-by: Marcel Zieba <marcel.zieba@isovalent.com>
@maintainer-s-little-helper maintainer-s-little-helper bot added the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Aug 13, 2025
@marseel marseel added the release-note/minor This PR changes functionality that users may find relevant to operating Cilium. label Aug 13, 2025
@maintainer-s-little-helper maintainer-s-little-helper bot removed the dont-merge/needs-release-note-label The author needs to describe the release impact of these changes. label Aug 13, 2025
@marseel marseel force-pushed the pr/marseel/improve_lbipam branch from 8f30f68 to 0039aeb Compare August 13, 2025 14:18
@marseel marseel changed the title Pr/marseel/improve lbipam lbipam: widening CIDR range or updating selector of CiliumLoadBalancerIPPool does no longer reassign IPs Aug 13, 2025
Additionally, in case of pool spec changes, log previous and new spec.

Signed-off-by: Marcel Zieba <marcel.zieba@isovalent.com>
@marseel marseel force-pushed the pr/marseel/improve_lbipam branch from 0039aeb to 7309eba Compare August 13, 2025 14:28
@marseel
Copy link
Copy Markdown
Member Author

marseel commented Aug 13, 2025

/test

@marseel marseel marked this pull request as ready for review August 13, 2025 14:48
@marseel marseel requested review from a team as code owners August 13, 2025 14:48
@marseel marseel requested review from aditighag and gandro August 13, 2025 14:48
Copy link
Copy Markdown
Member

@gandro gandro left a comment

Choose a reason for hiding this comment

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

ACK for logfields change

@marseel marseel added the needs-backport/1.18 This PR / issue needs backporting to the v1.18 branch label Aug 13, 2025
@joamaki joamaki added this pull request to the merge queue Aug 14, 2025
Merged via the queue into main with commit 5e4e4bf Aug 14, 2025
350 of 359 checks passed
@joamaki joamaki deleted the pr/marseel/improve_lbipam branch August 14, 2025 09:37
@joamaki joamaki mentioned this pull request Aug 19, 2025
19 tasks
@joamaki joamaki added backport-pending/1.18 The backport for Cilium 1.18.x for this PR is in progress. and removed needs-backport/1.18 This PR / issue needs backporting to the v1.18 branch labels Aug 19, 2025
@github-actions github-actions bot added backport-done/1.18 The backport for Cilium 1.18.x for this PR is done. and removed backport-pending/1.18 The backport for Cilium 1.18.x for this PR is in progress. labels Aug 21, 2025
terassyi added a commit to cybozu-go/cilium that referenced this pull request Dec 12, 2025
Signed-off-by: terashima <tomoya-terashima@cybozu.co.jp>
terassyi added a commit to cybozu-go/cilium that referenced this pull request Dec 12, 2025
* backport cilium/pull/41122

Signed-off-by: terashima <tomoya-terashima@cybozu.co.jp>

* backport cilium/pull/41147

lbipam: do not reallocate IPs on operator restart

If there was a pool that was filled and had unsatisfied Services, on
operator restart there was a high chance that we will reshuffle
assignement of IPs for that pool. This resulted in previously safisfied
services to either become unsatisfied or get a new IP.

Issue is fixed by not performing any operation on services until full
sync happens. After that, first we try to reuse IPs for already
satisfied services and only after that we try to assign additional IPs
to unsatisfied services.

Additionally, add test that covers this case, simulating restart of
operator.

Related: cilium#40358

Signed-off-by: Marcel Zieba <marcel.zieba@isovalent.com>

---------

Signed-off-by: terashima <tomoya-terashima@cybozu.co.jp>
Signed-off-by: Marcel Zieba <marcel.zieba@isovalent.com>
Co-authored-by: Marcel Zieba <marcel.zieba@isovalent.com>
yokaze pushed a commit to cybozu-go/cilium that referenced this pull request Jan 30, 2026
* backport cilium/pull/41122

Signed-off-by: terashima <tomoya-terashima@cybozu.co.jp>

* backport cilium/pull/41147

lbipam: do not reallocate IPs on operator restart

If there was a pool that was filled and had unsatisfied Services, on
operator restart there was a high chance that we will reshuffle
assignement of IPs for that pool. This resulted in previously safisfied
services to either become unsatisfied or get a new IP.

Issue is fixed by not performing any operation on services until full
sync happens. After that, first we try to reuse IPs for already
satisfied services and only after that we try to assign additional IPs
to unsatisfied services.

Additionally, add test that covers this case, simulating restart of
operator.

Related: cilium#40358

Signed-off-by: Marcel Zieba <marcel.zieba@isovalent.com>

---------

Signed-off-by: terashima <tomoya-terashima@cybozu.co.jp>
Signed-off-by: Marcel Zieba <marcel.zieba@isovalent.com>
Co-authored-by: Marcel Zieba <marcel.zieba@isovalent.com>
@cilium-release-bot cilium-release-bot bot moved this to Released in cilium v1.19.0 Feb 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport-done/1.18 The backport for Cilium 1.18.x for this PR is done. release-note/minor This PR changes functionality that users may find relevant to operating Cilium.

Projects

No open projects
Status: Released

Development

Successfully merging this pull request may close these issues.

4 participants