[CONTP-2030] Operator monitors DCA and CLC health #3487
<a target='_blank' href='https://app.datadoghq.com/ci/code-coverage/github.com%2Fdatadog%2Fdatadog-operator/pull-requests/3487'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/code-coverage-error.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/code-coverage-error-light.svg" alt="Code Coverage" align="center" /></picture></a>
🛑 Gate Violations
### 🎯 1 Code Coverage issue detected
A _Patch coverage percentage_ gate may be blocking this PR.
> • <b>Patch coverage</b>: 67.30% (threshold: 80.00%)
ℹ️ Info
🎯 Code Coverage (<a target='_blank' href='https://app.datadoghq.com/ci/code-coverage/github.com%2Fdatadog%2Fdatadog-operator/pull-requests/3487'>details</a>)<br>• <strong><span title="Percentage of modified executable lines covered by tests in this PR">Patch Coverage</span></strong>: 67.30%<br>• <strong><span title="Percentage of all executable lines covered by tests in the entire codebase">Overall Coverage</span></strong>: 52.08% <span title="Change in overall coverage compared to the base branch">(+0.41%)</span><br>
Useful? React with 👍 / 👎
<sub>
This comment will be updated automatically if new data arrives. <br />
🔗 Commit SHA: b54da13 | <a href="https://docs.datadoghq.com/integrations/guide/source-code-integration/#pr-comments">Docs</a> | Give us <a href="https://dd.enterprise.slack.com/archives/C07E3U2QRMM">feedback</a>!
</sub>
<sub><sub>!P2 Badge</sub></sub> Aggregate the active gauge across watched namespaces
When DD_AGENT_WATCH_NAMESPACE contains multiple namespaces, reported tracks each namespace separately but this gauge omits the namespace label and overwrites the shared series with only the last namespace's pod count. For example, resolving the last affected pod in namespace B sets the gauge to zero even if namespace A still has affected pods, so the advertised > 0 active-issue query becomes false; either include the namespace in the labels or calculate the total across all matching namespace states before calling Set.
Useful? React with 👍 / 👎.
<sub><sub>!P2 Badge</sub></sub> Retain full status only for managed component pods
When component health is combined with UntaintControllerWaitForCSIDriver, the earlier branch deliberately removes the Pod label selector, so this unconditional feature check copies container and init-container statuses for every Pod in all merged Agent/CSI watch namespaces, not just DCA/CLC pods. In a broad or cluster-wide watch this defeats the cache's memory stripping and can substantially increase operator memory or cause OOMs; gate these extra fields on the managed component label while retaining only the readiness fields required by untaint for other Pods.
Useful? React with 👍 / 👎.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 846d87b7d4
<details> <summary>ℹ️ About Codex in GitHub</summary>
<br/>
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
</details>
this needs to be cached too, PR only caches some of pod.Status fields only.
nit, should this use dedicated prefix?componenthealth_issues_detected_total or agenthealth_issues_detected_total instead of datadogagent_component_health_issues_detected_total.
in the app it will get datadog.operator prefix right?
Approved these changes.
Good catch. Updating the caching to include DeletionTimestamp
Approved these changes.
levan-m
adel121
What does this PR do?
Implements first version of component health, monitoring common issues for DCA and CLC on the cluster level:
component_oomkilledcomponent_crash_loopingcomponent_unschedulableimage_pull_failure2 things should change in a follow-up PR:
Emit/Resolveactions should be asynchronous to avoid blocking the main flow.The health component is disabled by default.
Describe your test plan
No need to QA this PR alone because it is a partial implementation, feature is new and disabled by default.
Full QA or E2E tests shall apply on the follow-up PR.
Checklist
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel[1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits