← Back to Pull requests

[CASCL-338] kubectl datadog autoscaling dpa: wait without list, validate container names #3680

Open
unknown opened this pull request with 306 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 28, 2026 13:24 UTC
Author

What does this PR do?

Fixes the two Codex findings raised on the v1.32 backport #3677 of #3558, in the kubectl datadog autoscaling dpa commands:

  • Poll named objects without requiring list (dpa/common/command.go): the status wait after patching listed every DatadogPodAutoscaler in the namespace. DPAs selected by name (without -A) are now read with Get. Deleted objects are skipped, as before. Selections by -l, --all or -A still use one List per namespace.

  • Reject invalid container names (dpa/forceresources/value.go): force-resources set -c accepted any non-empty name (bad name, APP). Container names are now validated as DNS-1123 labels, both for --container (before connecting to the cluster) and for the current annotation value.
  • Motivation

  • With RBAC that grants get/patch on named DPAs only (resourceNames), the patch succeeded, but the wait could not list. The command then waited until the timeout and exited non-zero, even though the override was applied.

  • No container can have an invalid name, so the Cluster Agent ignored the override. The command timed out and left an unusable annotation behind.
  • Additional Notes

  • An existing annotation that contains an invalid name now fails set for that object, and unset -c for it. The error already says to run unset without -c, which removes the whole annotation.

  • Once merged, this should be backported to v1.32 along with #3677, or the fix cherry-picked into that backport.
  • Minimum Agent Versions

    No change.

    Describe your test plan

  • New unit test TestWaitForConfirmationGetsNamedObjects: with List forbidden, a named selection is confirmed through Get, and a deleted object is ignored. Names with -A still use List. The test fails without the fix.

  • New cases for invalid container names in TestParseValueMatchesTheAgent and TestSetValidatesFlags.

  • go test ./cmd/kubectl-datadog/autoscaling/... and go vet pass locally. golangci-lint was not run locally, so it is left to CI.
  • Checklist

  • PR has at least one valid label: bug, enhancement, refactoring, documentation, tooling, and/or dependencies

  • PR has a milestone or the qa/skip-qa label

  • All commits are signed (see: [signing commits][1])
  • [1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits

    🤖 PR description and code assisted by Claude:claude-opus-5-5

    Diff: 306 lines (+229 / -77) across 3 files Reviewer: clamoriniere Review duration: 48466m
    All Vouch review confidence checks passed
    Residual risk 0.39 = Change Risk (0.70) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.70 · 306 lines diff across 3 files
    0.70
    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%
    44%
    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
    Shallow Review Depth shallow_review_depth
    0.344
    Diff Size diff_size
    0.343
    Sensitive Paths sensitive_paths
    0.070
    Real PR Conversation Timeline
    1 comments
    "Review active on #3680"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: medium confidence: 44.7% reviewed sensitive_module
    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: 70.4% (HIGH) · Higher = larger blast radius
    70.4%
    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: 44.7% · Lower = rushed or shallow review
    44.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: 38.9% · Moderate risk
    38.9%