fix(autoscaling): discard invalid PodAutoscaler settings instead of panicking #60599
All Vouch review confidence checks passed
Residual risk 0.22 = Change Risk (0.42) × (1 − Review Confidence (0.47)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.42 · 331 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.347
Shallow Review Depth
shallow_review_depth
0.344
Real PR Conversation Timeline
1 comments
"Review active on #60599"
general
weight: 0.35
AlexanderYastrebov
What does this PR do?
Fixes a Cluster Agent crash in the workload autoscaling Remote Config settings processor, and adds a test for it.
In
processItem(pkg/clusteragent/autoscaling/workload/config_retriever_settings.go), the loop oversettingsList.Settingscheckedsettings.Namespace == "" || settings.Name == "" || spec == niland appended a "discarding" error, but did not skip the entry. It then ranspec.RemoteVersion = pointer.Ptr(...):spec/specs, or withspecs: {}, the spec is nil and that line panicked with a nil pointer dereference, crashing the Cluster Agent.no-namespace,ns/) instead of being dropped.The fix adds
continueafter appending the error, so invalid entries are really discarded. Nothing downstream assumes every entry was stored:processorCallbackstill reportsApplyStateErrorfor that config to Remote Config and records it forcluster-agent status.lastProcessingErroris still set, soreconcilestill skips deleting existing PodAutoscalers that are missing from a partly invalid update.It also adds a
releasenotes-dcanote, since customers can hit this crash.Motivation
One malformed settings entry from Remote Config, for example
{"namespace":"ns","name":"foo"}with no spec, crashed the Cluster Agent.Describe how you validated your changes
TestAutoscalingSettingsProcessorDiscardsInvalidSettings(inconfig_retriever_settings_test.go) sends oneCONTAINER_AUTOSCALING_SETTINGSpayload holding a valid entry and an invalid one. It checks that processing does not panic, that the error is returned andlastProcessingErroris set, and that only the valid entry is kept. It has four cases:missing_spec,empty_specs,empty_namespaceandempty_name. It failed onmain(two panics and two extra stored IDs) and passes with the fix.ddais not installed in this workspace, so I ran the package's Bazel target directly:bazel test //pkg/clusteragent/autoscaling/workload:workload_test_dca --test_filter=TestAutoscalingSettingsProcessorDiscardsInvalidSettings --test_arg=-test.v: all four subtests pass.bazel test //pkg/clusteragent/autoscaling/workload:workload_test_dca: passes.gofmt -lis clean.Additional Notes
The first commit adds the failing test and the second adds the fix, so the test can be seen failing on its own commit.
🤖 Generated with Claude Code