Repository navigation
Treat semantically-equal IP pool CIDRs as equal - #4918
Merged
Merged
Conversation
After upgrading, an Installation that specifies an IPv6 pool CIDR in a
non-canonical form (e.g. with leading zeros, "fd20:5213:94f6:01e9:001f::/96")
caused the IP pool controller to enter an infinite delete/recreate loop. The
Calico API server normalizes CIDRs when it stores IP pools, so the persisted
pool has the canonical CIDR ("fd20:5213:94f6:1e9:1f::/96"). The controller
compared CIDRs as raw strings, decided the existing pool was not the one
described in the Installation, deleted it, and recreated it -- which the API
server then re-normalized, repeating forever.
Compare CIDRs by their canonical form everywhere the controller keys or
matches pools by CIDR (ownership lookup, adoption of pre-existing pools,
not-owned detection, create/update decision, and the delete check), and emit
the canonical CIDR when creating/updating pools so the stored resource matches
what we expect and is accepted by API server versions that reject
non-canonical CIDRs.
Fixes tigera#4783
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
caseydavenport
approved these changes
Jun 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Bug fix for the IP pool controller (
pkg/controller/ippool).When an
Installationspecifies an IPv6 pool CIDR in a non-canonical form (e.g. with leading zeros,fd20:5213:94f6:01e9:001f::/96), the controller entered an infinite delete/recreate loop:fd20:5213:94f6:1e9:1f::/96), because the Calico API server normalizes CIDRs vianet.ParseCIDRwhen persisting pools.p.CIDR == cidr), so it concluded the existing pool was not the one described in theInstallation.InstallationCIDR β which the API server re-normalized β returning to step 1, forever.Why merge: this leaves affected clusters with an operator that churns IP pools indefinitely after upgrade; the only workaround today is to hand-edit the CIDR into canonical form.
Fix: compare CIDRs by their canonical form (
net.IPNet.String()) everywhere the controller keys or matches pools by CIDR β theourPoolsownership map, adoption of pre-existing unlabelled pools, thenotOursnot-owned detection, the create/update decision, and the delete check. The controller also now emits the canonical CIDR when creating/updating pools (ToProjectCalico) so the written resource matches what the API server stores (avoiding needless updates) and is accepted by API server versions that reject non-canonical CIDRs (see projectcalico/calico#11385). Unparseable CIDRs fall back to exact string comparison.Components affected: IP pool controller only.
Testing:
make ut UT_DIR=./pkg/controller/ippoolpasses;gofmtclean.Fixes #4783
Release Note
For PR author
make gen-filesmake gen-versionsFor PR reviewers
A note for code reviewers - all pull requests must have the following:
kind/bugif this is a bugfix.kind/enhancementif this is a a new feature.enterpriseif this PR applies to Calico Enterprise only.