← Back to Pull requests

Make monitor state polling opt-out via DD_STATE_POLLING_ENABLED #3825

Closed
unknown closed this pull request without merging on Nov 23, 2026 08:32 UTC
View on GitHub
unknown unknown commented on Nov 19, 2026 19:57 UTC
Author

What does this PR do?

CONTP-2338

Adds DD_STATE_POLLING_ENABLED (default true), shared by the DatadogMonitor and DatadogGenericResource controllers. When set to false:

  • The periodic live-state refresh (GET) is skipped. Create, update and force sync work as before.

  • Idle resources requeue at the next force-sync deadline instead of every requeue period.

  • Status shows that polling is off: monitorState / state is set to PollingDisabled, polled timestamps, triggered state and downtime status are cleared, and a StateSynced=False condition with reason PollingDisabled is added. For GenericResource this applies only to types with live state (monitor, SLO).
  • Re-enabling polling clears PollingDisabled and refreshes state on the next idle reconcile.

    If the env var is unset, the operator logs an error at startup, because the default will change to false in a future release.

    Motivation

    Reduce Datadog API calls and reconcile churn from per-minute state polling. The Helm chart will control the setting during the transition.

    Additional Notes

  • With polling disabled, a monitor deleted out-of-band is recreated at the next force sync rather than within a polling period.

  • DD_MONITOR_FORCE_SYNC_PERIOD below 1 minute now falls back to 60 minutes, matching the GenericResource controller. Otherwise disabled polling would stop monitor requeues.

  • GenericResource handlers declare live state by implementing the optional liveStateRefresher interface; the no-op refreshState stubs are removed.
  • Describe your test plan

    Unit tests: go test ./pkg/controller/utils/ ./internal/controller/datadogmonitor/ ./internal/controller/datadoggenericresource/

    Manual:
    1. Deploy the operator with DD_STATE_POLLING_ENABLED=false and apply a DatadogMonitor.
    2. kubectl get datadogmonitor shows monitor state = PollingDisabled. status.conditions has StateSynced=False, reason PollingDisabled. Operator logs show no per-minute state refresh.
    3. Set it to true and restart: the real monitor state appears and the StateSynced condition is removed.
    4. Remove the env var and restart: the operator logs an error saying DD_STATE_POLLING_ENABLED is not set, and polling stays on.

    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

    🤖 Generated with Claude Code

    Diff: 330 lines (+247 / -83) across 4 files Reviewer: levan-m Review duration: 5075m
    All Vouch review confidence checks passed
    Residual risk 0.17 = Change Risk (0.42) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.42 · 330 lines diff across 4 files
    0.42
    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.347
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3825"
    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: 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: 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: 16.6% · Safe to merge
    16.6%