← Back to Pull requests

[CONTP-2136] Implement componenthealth snapshot emitter #3536

Closed
unknown closed this pull request without merging on Oct 12, 2026 17:11 UTC
View on GitHub
unknown unknown commented on Sep 30, 2026 12:56 UTC
Author

What does this PR do?

This PR evolves the component health implementation with a snapshot emitter that allows sending ACTIVE issues to the agent health intake on a fixed cadence, along with resolution signals when an issue resolves.

Things to know:

  • Detected issues are not persisted on disk. Issues are kept in-memory. So a restart during which an issue is physically resolved will miss sending resolution signal to the backend. This gap will be closed in a follow-up PR.

  • Remediation is currently hardcoded in the code. However, the backend should provide backend-backed remediations based on issue-id. Once remediations of these issues are backed by the backend, we should be able to drop them from the operator code and let the backend handle remediation steps.

  • The Component Health maintains 2 implementations of the emitted:

  • - log emitter: only logs snapshots of issues into operator logs; used by default when submitting to intake is disabled in operator feature flags (which is the default)
    - snapshot emitter: submits issues and resolution signals to the intake (if the feature flag is activated)

    Describe your test plan

    Added unit tests.

    Manual testing:

    Deployed a faulty agent stack.

    E.g.

    apiVersion: datadoghq.com/v2alpha1
    kind: DatadogAgent
    metadata:
      name: datadog
      namespace: system
    spec:
      global:
        clusterName: health-compv2
        kubelet:
          tlsVerify: false
        credentials:
          apiKey: "00000000000000000000000000000000"
          appKey: "0000000000000000000000000000000000000000"
      override:
        clusterAgent:
          image:
            name: gcr.io/datadoghq/cluster-agent
            tag: this-tag-does-not-exist-health-compv2
            pullPolicy: Always
    
        # ----------------------------------------------------------------------------
        # Alternative failure modes to test other issue types — uncomment ONE instead
        # of (or in addition to) the bad image override above.
        #
        # component_oomkilled: starve the Cluster Agent of memory so it is OOMKilled.
        # (Remove the `image:` override above if you want a valid image that OOMs.)
          containers:
            cluster-agent:
              resources:
                limits:
                  memory: 20Mi
        #
        # You can do the same against the Cluster Checks Runner (also monitored) by
        # enabling it and overriding `clusterChecksRunner` the same way:
        #   features:
        #     clusterChecks:
        #       enabled: true
        #       useClusterChecksRunners: true
        #   override:
        #     clusterChecksRunner:
        #       image:
        #         tag: this-tag-does-not-exist-health-compv2
        #         pullPolicy: Always
        # # ----------------------------------------------------------------------------
    
    

    {"level":"DEBUG","ts":"2026-10-02T13:40:01.676Z","logger":"controllers.ComponentHealth","msg":"component health snapshot: no active or resolved issues"}
    
    {"level":"DEBUG","ts":"2026-10-02T13:40:01.976Z","logger":"metadata.operator","msg":"Error while sending metadata","error":"error creating request: DatadogAgent not found"}
    
    {"level":"DEBUG","ts":"2026-10-02T13:41:01.675Z","logger":"controllers.ComponentHealth","msg":"component health snapshot: no active or resolved issues"}
    
    {"level":"INFO","ts":"2026-10-02T13:41:04.197Z","logger":"controllers.ComponentHealth","msg":"component health issue detected","component":"cluster-agent","issue_type":"image_pull_failure","severity":"medium","namespace":"system","affected_pods":["datadog-cluster-agent-5c7645946-sr7sl"]}
    
    {"level":"DEBUG","ts":"2026-10-02T13:42:01.675Z","logger":"controllers.ComponentHealth","msg":"component health snapshot","active":1,"resolved":0,"active_issues":[{"Component":"cluster-agent","IssueType":"image_pull_failure","Severity":"medium","Namespace":"system","AffectedPods":["datadog-cluster-agent-5c7645946-sr7sl"],"FirstSeen":"2026-10-02T13:41:04.197544674Z","LastSeen":"2026-10-02T13:41:50.289918126Z","ResolvedAt":"0001-01-01T00:00:00Z"}],"resolved_issues":[]}
    
    {"level":"INFO","ts":"2026-10-02T13:49:34.415Z","logger":"controllers.ComponentHealth","msg":"component health issue detected","component":"cluster-checks-runner","issue_type":"image_pull_failure","severity":"medium","namespace":"system","affected_pods":["datadog-cluster-checks-runner-6cdfd85978-s2bqg"]}
    {"level":"INFO","ts":"2026-10-02T13:49:34.423Z","logger":"controllers.ComponentHealth","msg":"component health issue detected","component":"cluster-agent","issue_type":"component_oomkilled","severity":"high","namespace":"system","affected_pods":["datadog-cluster-agent-78f6bcb97d-kfh6b"]}
    {"level":"INFO","ts":"2026-10-02T13:49:36.420Z","logger":"controllers.ComponentHealth","msg":"component health issue detected","component":"cluster-agent","issue_type":"component_crash_looping","severity":"high","namespace":"system","affected_pods":["datadog-cluster-agent-78f6bcb97d-kfh6b"]}
    

    Now update the DDA CR to a version that would run fine, then verify the operator resolves the issues:

    NAME                                             READY   STATUS                       RESTARTS        AGE
    datadog-agent-spmbk                              2/3     Running                      0               2m46s
    datadog-cluster-agent-78f6bcb97d-kfh6b           0/1     CrashLoopBackOff             4 (3m33s ago)   5m14s
    datadog-cluster-agent-7dbdf5dfb4-nhfjp           0/1     CreateContainerConfigError   0               2m46s
    datadog-cluster-checks-runner-6cdfd85978-s2bqg   0/1     Init:ImagePullBackOff        0               5m14s
    datadog-cluster-checks-runner-84868c58c6-g6jv9   0/1     CreateContainerConfigError   0               2m46s
    datadog-operator-manager-ffd8c69fd-m2xqz         1/1     Running                      0               16m
    datadog-cluster-checks-runner-84868c58c6-g6jv9   0/1     Running                      0               2m47s
    datadog-cluster-agent-7dbdf5dfb4-nhfjp           0/1     Running                      0               2m56s
    datadog-agent-spmbk                              2/3     Running                      0               3m
    datadog-agent-spmbk                              3/3     Running                      0               3m
    

    NAME                                             READY   STATUS    RESTARTS   AGE
    datadog-agent-spmbk                              3/3     Running   0          3m17s
    datadog-cluster-agent-7dbdf5dfb4-nhfjp           1/1     Running   0          3m17s
    datadog-cluster-checks-runner-84868c58c6-g6jv9   1/1     Running   0          3m17s
    datadog-operator-manager-ffd8c69fd-m2xqz         1/1     Running   0          17m
    

    We should see the issue being resolved in the logs:

    {"level":"INFO","ts":"2026-10-02T13:55:10.661Z","logger":"controllers.ComponentHealth","msg":"component health issue resolved","component":"cluster-checks-runner","issue_type":"image_pull_failure","namespace":"system"}
    {"level":"INFO","ts":"2026-10-02T13:55:10.729Z","logger":"controllers.ComponentHealth","msg":"component health issue resolved","component":"cluster-agent","issue_type":"component_oomkilled","namespace":"system"}
    {"level":"INFO","ts":"2026-10-02T13:55:10.729Z","logger":"controllers.ComponentHealth","msg":"component health issue resolved","component":"cluster-agent","issue_type":"component_crash_looping","namespace":"system"}
    
    {"level":"DEBUG","ts":"2026-10-02T13:56:01.670Z","logger":"controllers.ComponentHealth","msg":"component health snapshot","active":0,"resolved":3,"active_issues":[],"resolved_issues":[{"Component":"cluster-agent","IssueType":"component_crash_looping","Severity":"high","Namespace":"system","AffectedPods":null,"FirstSeen":"2026-10-02T13:54:16.287184555Z","LastSeen":"2026-10-02T13:54:16.287184555Z","ResolvedAt":"2026-10-02T13:55:10.729660636Z"},{"Component":"cluster-agent","IssueType":"component_oomkilled","Severity":"high","Namespace":"system","AffectedPods":null,"FirstSeen":"2026-10-02T13:49:56.526412379Z","LastSeen":"2026-10-02T13:54:16.287180555Z","ResolvedAt":"2026-10-02T13:55:10.729653927Z"},{"Component":"cluster-checks-runner","IssueType":"image_pull_failure","Severity":"medium","Namespace":"system","AffectedPods":null,"FirstSeen":"2026-10-02T13:49:34.415011549Z","LastSeen":"2026-10-02T13:53:01.284712673Z","ResolvedAt":"2026-10-02T13:55:10.661170219Z"}]}
    

    Finally, once resolution is reported, and everything is healthy, the next snapshot should show 0 reported issues, 0 resolutions:

    {"level":"DEBUG","ts":"2026-10-02T13:57:01.669Z","logger":"controllers.ComponentHealth","msg":"component health snapshot: no active or resolved issues"}
    

    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

    Diff: 650 lines (+487 / -163) across 8 files Reviewer: adel121 Review duration: 17535m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    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.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3536"
    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: 52% (MEDIUM) · Higher = larger blast radius
    52%
    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: 20.5% · Safe to merge
    20.5%