fix: key topology groups on the normalized label key #3307
All Vouch review confidence checks passed
Residual risk 0.31 = Change Risk (0.57) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.57 · 563 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 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.379
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #3307"
general
weight: 0.35
semx
Description
NewRequirementnormalizes aliased label keys, sofailure-domain.beta.kubernetes.io/zonebecomestopology.kubernetes.io/zonefor instance (requirement.go:56, labels.go:250). EveryRequirementsmap is therefore keyed on the normalized key, and so isdomainGroups, which is built by iterating one (topology.go:119).Topology groups, however, keep the raw key the pod declared:
So a pod spreading on the beta key gets an empty domain universe, by construction, every time.
AddRequirementsthen can't find the candidate node's domain either (the node requirements map is normalized, the group key is not), and scheduling fails outright:Repro, against a NodePool spanning three zones:
The pods never schedule. Swap in
topology.kubernetes.io/zone, change nothing else, and a NodeClaim is created within seconds. Confirmed on a live cluster running Karpenter v1.14 with the AWS provider, where the nodes carry both spellings of the zone label, so this is not a missing-label artifact.The change normalizes the topology key at the three
NewTopologyGroupcall sites (topology spread, pod affinity/anti-affinity, inverse anti-affinity) and theirdomainGroupslookups, and inRegister/Unregister. This covers all five entries ofNormalizedLabels(beta zone, region, instance-type, arch, os), not just zone.Node labels are still read with the group's key, with no alias fallback. kube-scheduler matches topology keys literally, so a node carrying only the beta zone label must not count as a domain for a constraint on the stable key; a fallback would add it as an empty domain and block otherwise valid placements. As a result:
nodeSelectorand node affinity keys. On a cluster where nodes carry only one spelling, Karpenter and kube-scheduler can still disagree for such constraints. Topology spread and a pod's own (anti-)affinity on an aliased key could not schedule at all before this change; the anti-affinity of existing pods could, and a legacy-only node is no longer recognized there, which matches kube-scheduler as long as the nodes Karpenter launches don't carry the legacy label either.GetTopologyZoneConstraints, so it is reflected in thePendingPodsByEffectiveZonemetric.How was this change tested?
Three new specs in
topology_test.go:Zonal: four pods spread on the beta zone key, asserting a 1/1/2 skew over the stable key. Fails onmainwith the error above, passes with this change.Zonal: a node labeled only with the beta zone key, in a zone outside the NodePool, must not block a stable-key spread over the other zones. Passes onmain, and guards against matching node labels through aliases.Pod Affinity/Anti-Affinity: pods with required anti-affinity on the beta zone key schedule exactly as they do on the stable key. Fails onmainwith an unsatisfiable anti-affinity constraint.Full
make testgreen.By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.