← Back to Pull requests

[CASCL-338] feat(autoscaling): add pause and force-fallback ops annotations to DPA #56984

Closed
unknown closed this pull request without merging on Oct 01, 2026 21:35 UTC
View on GitHub
unknown unknown commented on Sep 27, 2026 15:10 UTC
Author

Stacked PR (1/3): #56985 (force-replicas annotation) is stacked on top of this branch, then #56988 (force-resources annotation) on top of it; they should merge in that order.

What does this PR do?

Adds two annotations on DatadogPodAutoscaler that let an operator change behaviour without editing the spec:

  • autoscaling.datadoghq.com/pause: "true" — the autoscaler applies nothing: no horizontal scaling, no vertical rollout or in-place resize, no admission-webhook pod patching. Manual edits to the target workload (replicas, container resources) are left alone. Pause is enforced where actions are applied, through a single CanApply() gate shared by the horizontal and vertical paths, and reported as Active=False with reason LocallyPaused.

  • autoscaling.datadoghq.com/force-fallback: "true" — handled like backend recommendations going stale, so the local fallback takes over even when backend values are fresh. It never overrides the spec: the local recommender still only runs when spec.fallback.horizontal.enabled allows it.
  • Gating the admission webhook matters as much as the controller here: ApplyRecommendations deliberately rewrites container resources to undo manual pod edits, so without it a user's Deployment change would silently not stick on replacement pods.

    Both annotations work whatever the owner (local, remote, profile-managed), so an operator can act in-cluster during an incident even on a remotely managed DPA. A value that isn't a valid boolean is ignored, as if the annotation were absent.

    On the telemetry side there's a new …autoscaling.workload.paused gauge, and …local.fallback_enabled now carries a fallback_trigger tag (stale vs forced). Worth a look during review: that tag changes an existing metric's series, and without it the metric becomes ambiguous the moment force-fallback ships, since the fallback can now be switched on by an operator rather than only by stale recommendations. metrics/metrics.md is updated for both.

    Motivation

    During an incident there's no way to stop a DPA short of editing the spec — applyPolicy.mode: Preview, disabling both scale directions, or deleting the object. All of those mutate desired state, so they fight GitOps and the profile syncer, and they're easy to forget to revert.

    Separately, the local fallback only engages once backend values go stale. Recommendations that are fresh but wrong currently have no escape hatch.

    Describe how you validated your changes

    Unit tests across the workload package, including that pause blocks each apply path separately, that drift isn't reverted while paused, and that the annotations are honoured for local-owner, remote-owner and profile-managed DPAs.

    The previous revision was also run on a local kind cluster against a real CRD (pause appears and clears, "false" and unparseable values don't pause, a remote-owner DPA annotated after being cached is picked up). The review rework (Active=False/LocallyPaused, CanApply(), force-fallback as a staleness trigger) is covered by unit tests; the kind run is to be redone on it.

    Additional Notes

    Two follow-ups, not in this PR: a kubectl datadog autoscaling dpa pause|fallback command group in datadog-operator, and replacing the ACTIVE/IN ERROR columns with a single computed STATUS column (needs a CRD field, so operator-first).

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

    Diff: 433 lines (+324 / -109) across 5 files Reviewer: clamoriniere Review duration: 6144m
    All Vouch review confidence checks passed
    Residual risk 0.18 = Change Risk (0.45) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.45 · 433 lines diff across 5 files
    0.45
    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.363
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #56984"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% 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: 45.2% (MEDIUM) · Higher = larger blast radius
    45.2%
    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: 17.8% · Safe to merge
    17.8%