feat(webhook): sort map iterations in webhook plugins and application injectors for deterministic mutation #6262
All Vouch review confidence checks passed
Residual risk 0.23 = Change Risk (0.43) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.43 · 355 lines diff across 4 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.351
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #6262"
general
weight: 0.35
cheyang
Ⅰ. Describe what this PR does
This PR ensures deterministic pod mutations across webhook plugins and FUSE application injectors by replacing unordered Go map iterations with
utils.OrderedKeys:1.
pkg/application/inject/fuse/mount_point_script.go:- In
assembleMountInfos, sortpath2RuntimeTypeMapkeys so colon-separatedmountPathStrandmountTypeStrinjected into containerlifecycle.postStartcommands are always deterministic.- Deterministically pick first valid runtime info namespace when multiple runtime infos exist (
utils.OrderedKeys(runtimeInfos)) with nil checks.- Update
mount_point_script_test.gowith strict equality assertions and stress test loops (50 iterations over fresh fake client instances).2.
pkg/webhook/plugins/fileprefetcher/file_prefetcher.go:- Sort
runtimeInfoskeys when building defaultfileList(pvc://...).- Sort
config.VolumeMountPathskeys when assembling sidecar container volume mounts.- Sort
config.ExtraEnvskeys when injecting extra environment variables into the prefetcher container.- Update
file_prefetcher_test.goto assert exact deterministic ordering on volume mounts, fileList env, and extra envs.3.
pkg/webhook/plugins/mountpropagationinjector/mount_propagation_injector.go:- Defensively sort
runtimeInfoskeys when collectingdatasetNamesfor deterministic debug logging.- Add unit test coverage for multiple
runtimeInfos.4.
pkg/webhook/plugins/datasetusageinjector/dataset_usage_injector.go:- Use
utils.OrderedKeysdirectly fordatasetsInUseslice generation.Ⅱ. Does this pull request fix one or more issues?
Follow-up to #6217 and #6234 to guarantee deterministic pod spec mutations and eliminate webhook mutation diffs / test flakiness across all injection sites.
Ⅲ. List the added test cases (unit test/integration test)
pkg/application/inject/fuse/mount_point_script_test.go:-
Context("when given multiple paths in random map order"): 50 iterations asserting exact sorted colon-separated output.-
Context("when multiple runtime infos are provided"): 50 iterations with fresh fake clients asserting deterministic namespace selection.pkg/webhook/plugins/fileprefetcher/file_prefetcher_test.go:- Exact equality assertion on
fileListEnv.Value.- Exact equality assertion on
volumeNames.- Added
It("should append extraEnvs in deterministic key-sorted order").pkg/webhook/plugins/mountpropagationinjector/mount_propagation_injector_test.go:- Added
It("should mutate pod with multiple runtimeInfos").Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews
None. All existing unit tests pass cleanly with zero API or CRD changes.