fix(utils): sort nodeSelector keys in MergeNodeSelectorAndNodeAffinity to guarantee deterministic order #6217
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.37) × (1 − Review Confidence (0.43)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.37 · 217 lines diff across 2 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
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.322
Real PR Conversation Timeline
1 comments
"Review active on #6217"
general
weight: 0.35
cheyang
Ⅰ. Describe what this PR does
In
pkg/utils/kubeclient/pod.go,MergeNodeSelectorAndNodeAffinityconvertsnodeSelectormap entries intocorev1.NodeSelectorRequirementmatch expressions. Because Go map iteration order is non-deterministic, multi-labelnodeSelectormaps resulted inMatchExpressionsslices in arbitrary order across reconciliation cycles.When controllers construct or compare status (such as
status.CacheAffinity), the fluctuating slice order caused status equality checks (reflect.DeepEqual) to detect spurious differences, triggering unnecessary API server status writes and re-reconciliation loops on every cycle.This PR sorts the keys of
nodeSelectoralphabetically before buildingMatchExpressions, guaranteeing deterministic output order across all cycles and runtimes (CacheRuntime, Alluxio, Jindo, JuiceFS, Thin, etc.).Ⅱ. Does this pull request fix one issue?
fixes #6216
Ⅲ. List the added test cases (unit test/integration test) if any, please explain if no tests are needed.
pkg/utils/kubeclient/pod_test.go:- Added test cases in
DescribeTablefor multi-label node selector (both with and without existingNodeSelectorTerms) verifying sortedMatchExpressionsorder.- Added regression tests running 100 repeated invocations on multi-label maps verifying byte-identical and order-identical output across calls for both fresh terms and appended terms.
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews