← Back to Pull requests

[Backport v1.32] [CASCL-338] Add kubectl datadog autoscaling dpa commands #3677

Closed
unknown closed this pull request without merging on Oct 30, 2026 13:13 UTC
View on GitHub
unknown unknown commented on Oct 28, 2026 12:38 UTC
Author

Backport b8216e26cd09c5333a4ba795bad7d7b6b32c3188 from #3558.

___

What does this PR do?

Adds kubectl datadog autoscaling dpa, a set of break-glass commands that set the DatadogPodAutoscaler operational annotations without touching the spec:

| Command | Annotation | Effect |
|---|---|---|
| pause enable\|disable | autoscaling.datadoghq.com/pause | Stop / resume applying any change to the workload |
| force-fallback enable\|disable | autoscaling.datadoghq.com/force-fallback | Force the local recommender as the horizontal source |
| force-replicas set\|unset | autoscaling.datadoghq.com/force-replicas | Pin the replica count |
| force-resources set\|unset | autoscaling.datadoghq.com/force-resources | Override container cpu/memory requests and limits (merged into the current value) |

Common behaviour:

  • Explicit selection only: names, -l/--label-selector, or --all. -A/--all-namespaces widens a selection and is rejected on its own.

  • Confirmation prompt when more than one object is selected (--yes to skip); --dry-run prints namespace/name: current → new.

  • Values are validated client-side, because the Cluster Agent silently ignores invalid ones.

  • After patching, waits (--timeout, default 30s; --wait=false to skip) for the Cluster Agent to report the override in the status:

  • - pause: Active=False, reason LocallyPaused
    - force-replicas: HorizontalScalingLimited, "replica count pinned to N …"
    - force-resources: VerticalScalingLimited, reason ForcedByAnnotation
    - force-fallback enable: status.horizontal.target.source=Local. Only a warning if not confirmed, since the local recommender may not have fresh values yet.
  • Ctrl-C aborts cleanly at the prompt, during patching, and during the wait.
  • Also fixes a typo in pkg/plugin/common/client.go ("unable to register").

    Motivation

    Give on-call engineers a safe, auditable way to pause or override DPA autoscaling during an incident, without editing the DPA spec by hand or remembering annotation formats.

    Additional Notes

  • Annotation keys and status strings match datadog-agent pkg/clusteragent/autoscaling/workload (DataDog/datadog-agent#56984, #56985, #56988). TestContractStrings pins them.

  • force-resources only applies while the DPA has a vertical recommendation; forced values are overlaid on it.

  • force-fallback disable only stops forcing the fallback; it does not disable spec.fallback.horizontal.enabled.
  • Minimum Agent Versions

    Agent: N/A
    Cluster Agent: v7.85.0

    Describe your test plan

  • Unit tests: go test -race ./cmd/kubectl-datadog/autoscaling/dpa/...

  • On a cluster running Cluster Agent 7.85.0 or later:

  • 1. kubectl datadog autoscaling dpa pause enable <dpa> → waits, prints "Confirmed by the Cluster Agent"; kubectl describe dpa shows Active=False/LocallyPaused.
    2. pause enable -A → rejected; pause enable --all -A --dry-run → lists objects.
    3. force-replicas set --replicas 5 <dpa> → workload scales to 5; unset releases it.
    4. force-resources set -c app --requests cpu=500m <dpa> then unset -c app.
    5. force-fallback enable <dpa> without fresh local values → warning, exit 0.
    6. Ctrl-C at the confirmation prompt (with --all) → aborts, nothing patched.

    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: 469 lines (+351 / -118) across 5 files Reviewer: clamoriniere Review duration: 2914m
    All Vouch review confidence checks passed
    Residual risk 0.27 = Change Risk (0.69) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.69 · 469 lines diff across 5 files
    0.69
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    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.368
    Shallow Review Depth shallow_review_depth
    0.289
    Sensitive Paths sensitive_paths
    0.069
    Real PR Conversation Timeline
    1 comments
    "Review active on #3677"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 68.8% (HIGH) · Higher = larger blast radius
    68.8%
    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: 60.5% · Lower = rushed or shallow review
    60.5%
    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: 27.2% · Safe to merge
    27.2%