fix(ipam): reject a wildcard IPPool selection that matches no IPPool #5862
All Vouch review confidence checks passed
Residual risk 0.18 = Change Risk (0.46) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 479 lines diff across 5 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.369
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #5862"
general
weight: 0.35
bolubo
Thanks for contributing!
Notice:
[x] unite test or E2E test
[x] do not forget essential code comment and log
[ ] document for the PR
[x] release note label:
release/bug[x] read about Contribution notice: <https://spidernet-io.github.io/spiderpool/latest/develop/contributing/>
What issue(s) does this PR fix:
Fixes #5849
Special notes for your reviewer:
ParseWildcardPoolNameListexpands wildcard IPPool names against the IPPools that already exist for the requested IP version, and a selection can also resolve to nothing when every pool listed belongs to an IP family that is disabled on the cluster. Either waypkg/ipamused to continue with an empty candidate list, the agent answered the CNI ADD with{"ips":null}, and the Pod failed withips in body is required, which points nowhere near the pool name.Following the review in this thread, the check sits in
genToBeAllocatedSetright aftercheckIPVersionEnable, so it covers every selection path once the candidates are filtered by family:ParseWildcardPoolNameListkeeps its signature and only logs a Warn when a pattern matches nothing, because it cannot know which IP families the caller has enabled.Scope notes:
The error wraps
constant.ErrNoAvailablePool, the sentinel the agent already counts atcmd/spiderpool-agent/cmd/ipam.go:172, so the failure now also shows up in the no-available-pool metric.The eight calls in
pkg/ipam/pool_selections.goare untouched. They cover four selection paths, each with an IPv4 and an IPv6 call: the Pod annotationipam.spidernet.io/ippools, the legacyippoolannotation, the namespace default pools, and the NAD fieldsdefault_ipv4_ippool/default_ipv6_ippool. They reach the new check throughgenToBeAllocatedSet.A mixed list such as
["vlan-a", "zero-"], wherevlan-aexists, still allocates, because one candidate is left. Per-pattern strictness is the separate question in #5861.A pool list of a disabled IP family now fails the same way an empty wildcard does, which is what the review asked for. One corner is still open in the thread: a multi-NIC
ippoolsentry that lists no pool at all.pkg/ippoolmanagerkeeps expecting no error for a zero-match wildcard, and two cases inpkg/ipamcover the disabled family and the empty wildcard.Manual reproduction of the original symptom is in #5849: the agent logged
Prechecked IPPool candidates: [{NIC:eth0 CleanGateway:false PoolCandidates:[]}], thenSucceed to allocate: {"ips":null}, and the Pod event wasips in body is required. The new check sits where that empty list shows up. After the review change I did not rerun the Pods, because my local kind lab is gone and rebuilding it needs the multus and controller images pulled again. I can do that before merge if you would like the real event.go test ./pkg/ippoolmanager ./pkg/ipampasses,gofmt -l,go vet ./pkg/ippoolmanagerandmake check_test_labelare clean. No user-facing documentation change. I did not add an E2E case, since the behaviour here is covered by the unit tests. Say if you want one in the IPAM suite and I will add it.AI disclosure: I used AI assistance to help write this change and its tests. The reproduction above and the code are mine.
Release note:
``
release-note
``A pool selection that leaves no IPPool candidate for a NIC, for example a wildcard that matches no IPPool or a pool list whose IP family is disabled, now fails with an explicit "no IPPool candidate left for NIC" error instead of leaving the Pod to fail with the unrelated "ips in body is required" message.