← Back to Pull requests

fix(autoscaling): discard invalid PodAutoscaler settings instead of panicking #60599

Open
unknown opened this pull request with 331 lines diff across 4 files
View on GitHub
unknown unknown commented on Nov 16, 2026 17:53 UTC
Author

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 over settingsList.Settings checked settings.Namespace == "" || settings.Name == "" || spec == nil and appended a "discarding" error, but did not skip the entry. It then ran spec.RemoteVersion = pointer.Ptr(...):

  • With no spec/specs, or with specs: {}, the spec is nil and that line panicked with a nil pointer dereference, crashing the Cluster Agent.

  • With a valid spec but an empty namespace or name, the entry was stored under a malformed ID (no-namespace, ns/) instead of being dropped.
  • The fix adds continue after appending the error, so invalid entries are really discarded. Nothing downstream assumes every entry was stored:

  • The joined error is still returned, so processorCallback still reports ApplyStateError for that config to Remote Config and records it for cluster-agent status.

  • lastProcessingError is still set, so reconcile still skips deleting existing PodAutoscalers that are missing from a partly invalid update.

  • The valid entries in the same payload are still stored and applied.
  • It also adds a releasenotes-dca note, 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 (in config_retriever_settings_test.go) sends one CONTAINER_AUTOSCALING_SETTINGS payload holding a valid entry and an invalid one. It checks that processing does not panic, that the error is returned and lastProcessingError is set, and that only the valid entry is kept. It has four cases: missing_spec, empty_specs, empty_namespace and empty_name. It failed on main (two panics and two extra stored IDs) and passes with the fix.

    dda is 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 -l is 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

    Diff: 331 lines (+248 / -83) across 4 files Reviewer: AlexanderYastrebov Review duration: 8763m
    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
    0.42
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.02 · 1 substantive comment(s)
    0.02
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    46%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    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
    Assignees
    Unassigned
    Labels
    risk: low confidence: 46.7% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 42.1% (MEDIUM) · Higher = larger blast radius
    42.1%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 46.7% · Lower = rushed or shallow review
    46.7%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 22.4% · Safe to merge
    22.4%