Skip to content

Cilium operator incorrectly calculates ExcessIPs when IPPrefixes are enabled #39904

@hsalluri259

Description

@hsalluri259

Cilium operator incorrectly calculates ExcessIPs when both IPPrefixes and Secondary IPAddresses are in use.
Below is an example where I have 4 individual IP addresses and one prefix allocated. So my Available IPs are 20(16 from prefix), UsedIPs are 16 because 8 of those IPs from prefix are in use so we can consider all of them are in use per this function. We do not need any IPs and preAllocate = 8

time=2025-06-04T22:38:19Z level=info msg="Available IPs are "  !BADKEY=20
time=2025-06-04T22:38:19Z level=info msg="usedIPForExcessCalc are" !BADKEY=16
time=2025-06-04T22:38:19Z level=info msg="neededIps are"  !BADKEY=0
time=2025-06-04T22:38:19Z level=info msg="ExcessIPs from ipam " !BADKEY=0

When we calculate excesss IPs in calculateExcessIPs function,
we have the below formula

excessIPs = max(availableIPs-usedIPs-preAllocate-maxAboveWatermark, 0)

By using above values if calculate excessIPs, it's -4 instead of 4 because we are using preAllocate in this case.

excessIPs = max(20-16-8-0, 0) = max(-4, 0) =0

I think the right math will be, so the operator will be able to remove those 4 IP addresses if they're free.

excessIPs = max(availableIPs-usedIPs-maxAboveWatermark, 0)

we are using cilium 1.17.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/agentCilium agent related.area/eniImpacts ENI based IPAM.area/ipamIP address management, including cloud IPAMarea/operatorImpacts the cilium-operator componentkind/bugThis is a bug in the Cilium logic.staleThe stale bot thinks this issue is old. Add "pinned" label to prevent this from becoming stale.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions