← Back to Pull requests

Start supporting the use case of no cluster agent #3549

Closed
agagniere closed this pull request without merging on Oct 16, 2026 15:07 UTC
View on GitHub
agagniere agagniere commented on Oct 02, 2026 22:43 UTC
Author

What does this PR do?

When the cluster agent is disabled, others components like the core agent should know about it, to stop trying to contact it.

1. DD_CLUSTER_AGENT_ENABLED hardcoded "true" — the foundational switch the node agent uses to decide whether to even try reaching a cluster agent. Wrong on every single node-agent container and the init-config init container, regardless of config. Root cause behind several of the symptoms below.
2. admissionController — runs a webhook server inside the cluster agent. With it disabled, the Service/RBAC still got created and webhooks still registered pointing at nothing — the Kubernetes API server would block pod admission trying to reach a webhook with no backend. Most severe single-feature bug; this is an outage risk, not just an orphan.
3. instrumentationCrd — defaults to enabled (agent ≥ 7.82.0). Node agent kept registering the instrumentation-checks autodiscovery provider and spamming connection errors against a cluster agent Service that doesn't exist.
4. serviceDiscovery — explicit false silently dropped; agent's own ≥7.78.0 auto-on default won instead.
5. kubeStateMetricsCore — default-enabled, orphaned RBAC+ConfigMap bound to a nonexistent ServiceAccount.
6. eventCollection — default-enabled, same RBAC-orphan shape.
7. orchestratorExplorer — default-enabled, RBAC orphan (node-side disable env var was already correct, only the cluster-agent-side RBAC leaked).
8. controlPlaneMonitoring — default-enabled, orphaned ConfigMaps.
9. CSPM — opt-in, but ties node-side check requirement to the cluster agent requirement; same RBAC-orphan shape.
10. autoscaling — opt-in, RBAC orphan (already tagged for component-scoped cleanup, so lower practical risk, but still shouldn't be created).
11. helmCheck — opt-in, RBAC orphan.
12. kubernetesActions — opt-in, RBAC orphan.
13. externalMetricsServer — opt-in, orphaned Service/RBAC/APIService.
14. appsec injector — opt-in (annotation/CRD-gated), RBAC orphan; lowest blast radius since it requires the most explicit user configuration to trigger at all.
15. serviceDiscovery — the disabled-state env var fix (item 4) only covered ManageNodeAgent; ManageSingleContainerNodeAgent was still a no-op, so under SingleContainerStrategy a disabled config never reached the unprivileged-single-agent container and the agent's own ≥7.78.0 auto-on default won anyway.
16. DCA token Secret and Service — created unconditionally in manageDDADependenciesWithDDAI regardless of override.clusterAgent.disabled, left behind with no consumer.
17. DD_CLUSTER_AGENT_AUTH_TOKEN — written on the node agent based on merged feature requirements only, not the override; after fixing item 16 this left a secretKeyRef pointing at a Secret that no longer exists, which would have broken pod startup.
18. enabledefault — always set ClusterAgent.IsRequired: true, so merging it with override.clusterAgent.disabled made checkComponentEnabledWithOverride treat every no-Cluster-Agent DatadogAgent as a feature/override conflict, persisting an OverrideReconcileConflict status condition on an otherwise supported configuration. Found by Copilot/Codex PR review.
19. clusterChecks — default-enabled, no clusterAgent.disabled gate at all; missed in the original audit. Left DD_EXTRA_CONFIG_PROVIDERS=clusterchecks endpointschecks on the node agent pointing at a Cluster Agent that would never dispatch those checks. Found by Codex PR review.

Motivation

For reInvent we want to provide DD features on top of the DDOT collector, and so require the DD agent, while features that can be done via OTel like k8s explorer are handled by DDOT. In particular this means that the cluster agent should not be present.

OTAGENT-1387

Testing

Added testdata/no-cluster-agent-dda.yaml + a golden-file fixture (internal/controller/testutils/renderer) that renders a DatadogAgent with the cluster agent disabled and several cluster-agent-dependent features (kubeStateMetricsCore, orchestratorExplorer, serviceDiscovery) also enabled, to lock in that no Cluster Agent Deployment/Service/RBAC/token Secret is produced and that the node agent resolves correctly on its own.

Docs

Added a "Running without the Cluster Agent" section to docs/cluster_agent_setup.md plus an example manifest (examples/datadogagent/datadog-agent-without-clusteragent.yaml) — previously override.clusterAgent.disabled was undocumented.

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

    [OTAGENT-1387]: https://datadoghq.atlassian.net/browse/OTAGENT-1387?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    Diff: 1667 lines (+1634 / -33) across 47 files Reviewer: dd-gplassard Review duration: 19703m
    All Vouch review confidence checks passed
    Residual risk 0.13 = Change Risk (0.72) × (1 − Review Confidence (0.81)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.72 · 1667 lines diff across 47 files
    0.72
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.69 · 5 substantive comment(s)
    0.69
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    81%
    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.400
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    19 items
    datadog-datadog-prod-us1-2[bot] datadog-datadog-prod-us1-2[bot] commented on Oct 02, 2026 22:56 UTC
    Bot

    <picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-ok.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-ok-light.svg" alt="Pipelines" align="center" /></picture> &nbsp;<a target='_blank' href='https://app.datadoghq.com/ci/code-coverage/github.com%2Fdatadog%2Fdatadog-operator/pull-requests/3549'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/code-coverage-ok.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/code-coverage-ok-light.svg" alt="Code Coverage" align="center" /></picture></a>

    🎯 Code Coverage (<a target='_blank' href='https://app.datadoghq.com/ci/code-coverage/github.com%2Fdatadog%2Fdatadog-operator/pull-requests/3549'>details</a>)<br>• <strong><span title="Percentage of modified executable lines covered by tests in this PR">Patch Coverage</span></strong>: 92.86%<br>• <strong><span title="Percentage of all executable lines covered by tests in the entire codebase">Overall Coverage</span></strong>: 53.95% <span title="Change in overall coverage compared to the base branch">(+1.43%)</span><br>

    <sub>
    This comment will be updated automatically if new data arrives. <br />
    🔗 Commit SHA: 4d3b88e | <a href="https://docs.datadoghq.com/integrations/guide/source-code-integration/#pr-comments">Docs</a> | <a href="https://app.datadoghq.com/ci/pull-request/Z2l0aHViLmNvbS9kYXRhZG9nL2RhdGFkb2ctb3BlcmF0b3IvMzU0OQ==?referrer=pr-comment">View more details</a> | Give us <a href="https://dd.enterprise.slack.com/archives/C07E3U2QRMM">feedback</a>!
    </sub>

    Copilot Copilot commented on code on Oct 05, 2026 11:36 UTC
    Code Review
    internal/controller/datadogagent/feature/servicediscovery/feature.go:1
    @@ -98,6 +108,16 @@ func (f *serviceDiscoveryFeature) ManageClusterAgent(managers feature.PodTemplat
     // ManageNodeAgent allows a feature to configure the Node Agent's corev1.PodTemplateSpec
     // It should do nothing if the feature doesn't need to configure it.
     func (f *serviceDiscoveryFeature) ManageNodeAgent(managers feature.PodTemplateManagers) error {
    +	// Add the env var to explicitly reflect the resolved enabled state.
    +	// Otherwise, this feature defaults to enabled in the Agent code for versions >= 7.78.0.
    +	managers.EnvVar().AddEnvVarToContainer(apicommon.CoreAgentContainerName, &corev1.EnvVar{
    +		Name:  common.DDServiceDiscoveryEnabled,
    +		Value: apiutils.BoolToString(&f.enabled),
    +	})

    This explicit override is skipped with SingleContainerStrategy: reconciliation calls ManageSingleContainerNodeAgent instead of this method, and that hook is still a no-op. A disabled service-discovery feature therefore omits DD_DISCOVERY_ENABLED=false from the unprivileged single-agent container, allowing the Agent >= 7.78 default to enable it again. Please have the single-container hook write the resolved value to UnprivilegedSingleAgentContainerName and add a regression case for that strategy.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 05, 2026 11:36 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    Copilot review overview

    🟡 Changes recommended

    Disabled service discovery is not propagated when using the single-container strategy.

    Review effort: Balanced
    Findings: 1 <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture>

    <details open>
    <summary><strong>Open (1)</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> [Apply discovery-disabled override for single-container agents](#discussion_r4183526891) · New

  • </details>

    <details>
    <summary><strong>What changed in this PR</strong></summary>

    Adds support for running node agents without a Cluster Agent.

    Changes:

  • Propagates the disabled Cluster Agent state to node-agent containers.

  • Suppresses Cluster Agent-dependent features and resources.

  • Adds regression coverage for disabled configurations.
  • | File | Description |
    | ---- | ----------- |
    | feature/​servicediscovery/​feature.go | Explicitly configures service discovery state. |
    | feature/​servicediscovery/​feature_test.go | Tests explicit disabling. |
    | feature/​orchestratorexplorer/​feature.go | Skips Cluster Agent resources when disabled. |
    | feature/​orchestratorexplorer/​feature_test.go | Tests disabled Cluster Agent behavior. |
    | feature/​kubernetesstatecore/​feature.go | Suppresses KSM Core resources. |
    | feature/​kubernetesstatecore/​feature_test.go | Tests suppression. |
    | feature/​kubernetesactions/​feature.go | Disables Kubernetes Actions. |
    | feature/​kubernetesactions/​feature_test.go | Tests disabling. |
    | feature/​instrumentationcrd/​feature.go | Disables Instrumentation CRD integration. |
    | feature/​instrumentationcrd/​feature_test.go | Tests disabling. |
    | feature/​helmcheck/​feature.go | Suppresses Helm check resources. |
    | feature/​helmcheck/​feature_test.go | Tests suppression. |
    | feature/​externalmetrics/​feature.go | Suppresses external metrics resources. |
    | feature/​externalmetrics/​feature_test.go | Tests suppression. |
    | feature/​eventcollection/​feature.go | Suppresses event collection resources. |
    | feature/​eventcollection/​feature_test.go | Tests suppression. |
    | feature/​enabledefault/​feature.go | Overrides Cluster Agent availability environment variables. |
    | feature/​enabledefault/​feature_test.go | Tests environment overrides. |
    | feature/​cspm/​feature.go | Disables CSPM without a Cluster Agent. |
    | feature/​cspm/​feature_test.go | Tests disabling. |
    | feature/​controlplanemonitoring/​feature.go | Suppresses control-plane monitoring resources. |
    | feature/​controlplanemonitoring/​feature_test.go | Tests suppression. |
    | feature/​autoscaling/​feature.go | Disables Cluster Agent-backed autoscaling. |
    | feature/​autoscaling/​feature_test.go | Tests disabling. |
    | feature/​appsec/​feature.go | Disables AppSec injection. |
    | feature/​appsec/​feature_test.go | Tests disabling. |
    | feature/​admissioncontroller/​feature.go | Prevents unbacked admission webhooks. |
    | feature/​admissioncontroller/​feature_test.go | Tests disabling. |
    </details>

    ---

    💡 <a href="/DataDog/datadog-operator/new/main?filename=.github/skills/code-review/SKILL.md" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Add a code-review agent skill</a> or configure MCP servers for context-aware, tailored reviews. <a href="https://docs.github.com/copilot/how-tos/use-copilot-agents/request-a-code-review/use-code-review?tool=webui#mcp-servers-and-agent-skills" class="Link--inTextBlock" target="_blank" rel="noopener noreferrer">Learn more in the docs.</a>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Oct 05, 2026 15:09 UTC
    Code Review
    internal/controller/datadogagent/feature/enabledefault/feature.go:1
    @@ -45,6 +49,10 @@ func (f *defaultFeature) Configure(dda metav1.Object, ddaSpec *v2alpha1.DatadogA
     	trueValue := true
     	f.owner = dda
     
    +	if clusterAgent, ok := ddaSpec.Override[v2alpha1.ClusterAgentComponentName]; ok {
    +		f.clusterAgentDisabled = apiutils.BoolValue(clusterAgent.Disabled)

    <sub><sub>!P2 Badge</sub></sub> Mark the supported no-Cluster-Agent mode as non-conflicting

    When clusterAgent.disabled is true, this only records a flag; the returned ClusterAgent.IsRequired remains true. checkComponentEnabledWithOverride therefore treats every no-Cluster-Agent DDAI as an OverrideReconcileConflict and the component reconciler persists that condition, even though the new documentation presents this as a supported configuration. Return a false Cluster Agent requirement in this mode so normal no-DCA installations do not remain in a conflict status.

    Useful? React with 👍 / 👎.

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Oct 05, 2026 15:09 UTC
    Code Review
    docs/cluster_agent_setup.md:1
    @@ -73,3 +73,27 @@ datadog-agent-hjlbg                          1/1     Running   0          33s
     ```
     
     [1]: https://github.com/DataDog/datadog-operator/blob/main/examples/datadogagent/datadog-agent-with-clusteragent.yaml
    +
    +## Running without the Cluster Agent
    +
    +The Cluster Agent is optional. If you don't need cluster-level features (Kubernetes State Metrics Core, Admission Controller, Cluster Checks, External Metrics Server, Orchestrator Explorer, etc.), you can disable it and run the node Agent on its own, for example: [`datadog-agent-without-clusteragent.yaml` file][2]:
    +
    +```yaml
    +apiVersion: datadoghq.com/v2alpha1
    +kind: DatadogAgent
    +metadata:
    +  name: datadog
    +spec:
    +  global:
    +    clusterName: my-example-cluster
    +    credentials:
    +      apiKey: "<DATADOG_API_KEY>"
    +
    +  override:
    +    clusterAgent:
    +      disabled: true
    +```
    +
    +With `spec.override.clusterAgent.disabled: true`, no Cluster Agent `Deployment`, `Service`, or RBAC is created, and the node Agent is configured to run without one (`DD_CLUSTER_AGENT_ENABLED` is set to `false`). Any feature under `spec.features` that requires the Cluster Agent (for example `kubeStateMetricsCore`, `admissionController`, `clusterChecks`, `externalMetricsServer`, or `orchestratorExplorer`) is automatically left disabled rather than producing a broken, half-configured deployment — remove `override.clusterAgent.disabled` if you later need any of those features.

    <sub><sub>!P2 Badge</sub></sub> Disable default Cluster Checks with the Cluster Agent

    Cluster Checks is defaulted to enabled, but feature/clusterchecks.Configure has no clusterAgent.disabled gate. Consequently this new no-Cluster-Agent configuration still enables the Cluster Checks provider on node agents (the committed golden contains DD_EXTRA_CONFIG_PROVIDERS=clusterchecks endpointschecks) even though this change removes the Cluster Agent Service that schedules those checks. Gate Cluster Checks along with the other Cluster-Agent-only features before documenting it as automatically disabled.

    Useful? React with 👍 / 👎.

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Oct 05, 2026 15:09 UTC
    Reviewer

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: 5d915997ba

    <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

  • Open a pull request for review

  • Mark a draft as ready

  • Comment "@codex review".
  • 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>

    Copilot Copilot commented on code on Oct 06, 2026 13:04 UTC
    Code Review
    internal/controller/datadogagent/feature/enabledefault/feature.go:1
    @@ -45,11 +49,24 @@ func (f *defaultFeature) Configure(dda metav1.Object, ddaSpec *v2alpha1.DatadogA
     	trueValue := true
     	f.owner = dda
     
    +	if clusterAgent, ok := ddaSpec.Override[v2alpha1.ClusterAgentComponentName]; ok {
    +		f.clusterAgentDisabled = apiutils.BoolValue(clusterAgent.Disabled)
    +	}
    +
    +	// IsRequired: false (rather than nil) tells the merge that the Cluster Agent is
    +	// explicitly disabled via override, so checkComponentEnabledWithOverride resolves
    +	// this as a clean disable instead of an override/feature conflict, as long as no
    +	// other feature still requires it.
    +	clusterAgentRequired := feature.RequiredComponent{
    +		IsRequired: &trueValue,
    +		Containers: []apicommon.AgentContainerName{apicommon.ClusterAgentContainerName},
    +	}
    +	if f.clusterAgentDisabled {
    +		clusterAgentRequired = feature.RequiredComponent{IsRequired: new(false)}

    This false wins over every feature requirement during merging, but not every Cluster-Agent-only feature is gated on the override. In particular, privateactionrunner.Configure still marks the Cluster Agent required for cluster-agent.datadoghq.com/private-action-runner-enabled; it is classified as enabled before this merge and ManageDependencies still creates its Cluster Agent ConfigMap (and can trigger the GKE Autopilot rejection gate), while this value silently suppresses the Deployment. Gate the cluster-side private action runner on override.clusterAgent.disabled as well, or centralize filtering of Cluster-Agent-only features before enabled-feature/dependency processing.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 06, 2026 13:04 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    Copilot review overview

    🟡 Changes recommended

    Cluster-side private action runner configuration remains enabled and can create dependencies or block reconciliation when the Cluster Agent is disabled.

    Review effort: Balanced
    Findings: 1 <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.png" alt="High severity" width="62" height="18" align="texttop"></picture>

    <details open>
    <summary><strong>Open (1)</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.png" alt="High severity" width="62" height="18" align="texttop"></picture> [Cluster Agent override leaves private action runner dependencies enabled](#discussion_r4195605503) · New

  • </details>

    <details>
    <summary><strong>Resolved since last review (1)</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> [Apply discovery-disabled override for single-container agents](#discussion_r4183526891)

  • </details>

    dd-gplassard dd-gplassard approved these changes on Oct 06, 2026 16:05 UTC
    Approved Reviewer

    Approved these changes.

    Copilot Copilot commented on code on Oct 06, 2026 16:05 UTC
    Code Review
    internal/controller/datadogagent/feature/enabledefault/feature.go:1
    @@ -45,11 +49,24 @@ func (f *defaultFeature) Configure(dda metav1.Object, ddaSpec *v2alpha1.DatadogA
     	trueValue := true
     	f.owner = dda
     
    +	if clusterAgent, ok := ddaSpec.Override[v2alpha1.ClusterAgentComponentName]; ok {
    +		f.clusterAgentDisabled = apiutils.BoolValue(clusterAgent.Disabled)
    +	}
    +
    +	// IsRequired: false (rather than nil) tells the merge that the Cluster Agent is
    +	// explicitly disabled via override, so checkComponentEnabledWithOverride resolves
    +	// this as a clean disable instead of an override/feature conflict, as long as no
    +	// other feature still requires it.
    +	clusterAgentRequired := feature.RequiredComponent{
    +		IsRequired: &trueValue,
    +		Containers: []apicommon.AgentContainerName{apicommon.ClusterAgentContainerName},
    +	}
    +	if f.clusterAgentDisabled {
    +		clusterAgentRequired = feature.RequiredComponent{IsRequired: new(false)}

    The explicit false now masks the Cluster Agent requirement from APM single-step instrumentation, but APM has not been taught to honor this override. feature/apm.Configure still initializes SSI and ManageNodeAgent can enable language-detection reporting when SSI is enabled, while this merge prevents the Cluster Agent that serves the admission instrumentation from being deployed. Gate only the SSI portion of APM on override.clusterAgent.disabled (while preserving ordinary node APM) so this does not produce another half-configured Cluster-Agent-dependent feature.

    copilot-pull-request-reviewer[bot] copilot-pull-request-reviewer[bot] commented on Oct 06, 2026 16:05 UTC
    Reviewer

    <!-- ccr-overview-v2 -->

    Copilot review overview

    🟡 Changes recommended

    APM single-step instrumentation remains partially configured node-side even though its Cluster Agent requirement is masked.

    Review effort: Balanced
    Findings: 1 <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture>

    <details open>
    <summary><strong>Open (1)</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/medium-v2-light.png" alt="Medium severity" width="62" height="18" align="texttop"></picture> [Gate APM SSI when Cluster Agent is explicitly disabled](#discussion_r4197643477) · New

  • </details>

    <details>
    <summary><strong>Resolved since last review (1)</strong></summary>

  • <picture><source media="(prefers-color-scheme: dark)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.svg"><img src="https://github.githubassets.com/static/images/icons/copilot-code-review/high-v2-light.png" alt="High severity" width="62" height="18" align="texttop"></picture> [Cluster Agent override leaves private action runner dependencies enabled](#discussion_r4195605503)

  • </details>

    agagniere agagniere commented on code on Oct 07, 2026 22:14 UTC
    Code Review
    internal/controller/datadogagent/feature/enabledefault/feature.go:1
    @@ -45,11 +49,24 @@ func (f *defaultFeature) Configure(dda metav1.Object, ddaSpec *v2alpha1.DatadogA
     	trueValue := true
     	f.owner = dda
     
    +	if clusterAgent, ok := ddaSpec.Override[v2alpha1.ClusterAgentComponentName]; ok {
    +		f.clusterAgentDisabled = apiutils.BoolValue(clusterAgent.Disabled)
    +	}
    +
    +	// IsRequired: false (rather than nil) tells the merge that the Cluster Agent is
    +	// explicitly disabled via override, so checkComponentEnabledWithOverride resolves
    +	// this as a clean disable instead of an override/feature conflict, as long as no
    +	// other feature still requires it.
    +	clusterAgentRequired := feature.RequiredComponent{
    +		IsRequired: &trueValue,
    +		Containers: []apicommon.AgentContainerName{apicommon.ClusterAgentContainerName},
    +	}
    +	if f.clusterAgentDisabled {
    +		clusterAgentRequired = feature.RequiredComponent{IsRequired: new(false)}

    False positive, test added to verify

    gabedos gabedos commented on code on Oct 08, 2026 19:10 UTC
    Code Review
    internal/controller/datadogagent/feature/enabledefault/feature.go:1
    @@ -73,12 +90,30 @@ func (f *defaultFeature) ManageClusterAgent(managers feature.PodTemplateManagers
     // if SingleContainerStrategy is enabled and can be used with the configured feature set.
     // It should do nothing if the feature doesn't need to configure it.
     func (f *defaultFeature) ManageSingleContainerNodeAgent(managers feature.PodTemplateManagers) error {
    -	return nil
    +	return f.overrideClusterAgentEnabledEnvVar(managers)
     }
     
     // ManageNodeAgent allows a feature to configure the Node Agent's corev1.PodTemplateSpec
     // It should do nothing if the feature doesn't need to configure it.
     func (f *defaultFeature) ManageNodeAgent(managers feature.PodTemplateManagers) error {
    +	return f.overrideClusterAgentEnabledEnvVar(managers)
    +}
    +
    +// overrideClusterAgentEnabledEnvVar corrects DD_CLUSTER_AGENT_ENABLED, which the default pod
    +// template scaffolding (component/agent/default.go) hardcodes to "true" on every agent
    +// container regardless of whether a Cluster Agent is actually being deployed.
    +func (f *defaultFeature) overrideClusterAgentEnabledEnvVar(managers feature.PodTemplateManagers) error {
    +	if !f.clusterAgentDisabled {
    +		return nil
    +	}
    +	envVar := &corev1.EnvVar{
    +		Name:  common.DDClusterAgentEnabled,
    +		Value: "false",
    +	}
    +	managers.EnvVar().AddEnvVar(envVar)
    +	// AddEnvVar only reaches regular containers; the init-config init container builds its
    +	// env vars from the same hardcoded-true default and needs the override too.
    +	managers.EnvVar().AddEnvVarToInitContainer(apicommon.InitConfigContainerName, envVar)

    minor nit: unsure if the init containers care about this value

    gabedos gabedos commented on code on Oct 08, 2026 19:13 UTC
    Code Review
    internal/controller/datadogagent/feature/servicediscovery/feature.go:1
    @@ -43,13 +44,22 @@ func (f *serviceDiscoveryFeature) ID() feature.IDType {
     
     // Configure is used to configure the feature from a v2alpha1.DatadogAgent instance.
     func (f *serviceDiscoveryFeature) Configure(_ metav1.Object, ddaSpec *v2alpha1.DatadogAgentSpec, _ *v2alpha1.RemoteConfigConfiguration) (reqComp feature.RequiredComponents) {
    +	f.enabled = resolveEnabled(ddaSpec)
     	f.useSystemProbeLite = false
    -	if resolveEnabled(ddaSpec) {
    +
    +	if f.enabled {
     		f.useSystemProbeLite = shouldEnableServiceDiscoveryByDefault(ddaSpec)
     		reqComp.Agent = feature.RequiredComponent{
     			IsRequired: new(true),
     			Containers: []apicommon.AgentContainerName{apicommon.CoreAgentContainerName, apicommon.SystemProbeContainerName},
     		}
    +	} else {

    I don't think the service discovery feature is related to the Cluster Agent. This feature isn't about k8s services. For whatever reason a service == a process which can be detected on the Agent via system-probe / system-probe-lite. This should remain on without the cluster agent.

    gabedos gabedos commented on code on Oct 08, 2026 20:07 UTC
    Code Review
    internal/controller/datadogagent/feature/enabledefault/feature.go:1
    @@ -73,12 +90,30 @@ func (f *defaultFeature) ManageClusterAgent(managers feature.PodTemplateManagers
     // if SingleContainerStrategy is enabled and can be used with the configured feature set.
     // It should do nothing if the feature doesn't need to configure it.
     func (f *defaultFeature) ManageSingleContainerNodeAgent(managers feature.PodTemplateManagers) error {
    -	return nil
    +	return f.overrideClusterAgentEnabledEnvVar(managers)
     }
     
     // ManageNodeAgent allows a feature to configure the Node Agent's corev1.PodTemplateSpec
     // It should do nothing if the feature doesn't need to configure it.
     func (f *defaultFeature) ManageNodeAgent(managers feature.PodTemplateManagers) error {
    +	return f.overrideClusterAgentEnabledEnvVar(managers)
    +}
    +
    +// overrideClusterAgentEnabledEnvVar corrects DD_CLUSTER_AGENT_ENABLED, which the default pod
    +// template scaffolding (component/agent/default.go) hardcodes to "true" on every agent
    +// container regardless of whether a Cluster Agent is actually being deployed.
    +func (f *defaultFeature) overrideClusterAgentEnabledEnvVar(managers feature.PodTemplateManagers) error {

    edge case: the datadog agent profiles set cluster agent to be disabled on the profiles because we don't want to re-create the DCA. However, the user may still have the DCA enabled in the original DDA. This would result in all Agents in profiles not being able to contact the cluster agent?

    https://github.com/DataDog/datadog-operator/pull/3586 would fix that edge case and needs to be merged alongside (ideally this is before/same day so that nightly images don't bug)... still thinking about other potential solutions.

    kangyili kangyili approved these changes on Oct 12, 2026 09:08 UTC
    Approved Reviewer

    Approved these changes.

    levan-m levan-m commented on Oct 13, 2026 22:10 UTC
    Contributor

    @agagniere, I changed milestone to 1.33 for to have a bit more time for reviewing and possibly changing the approach.
    override.Component.disabled conflates 'don't create component' with 'component doesn't exist' which leads to issues @gabedos mentioned above.
    DCA disabled check is in the wrong place in my opinion. Bunch of features duplicate identical check to compute required components based on the override and exit early. requiredComponent is more nuanced, based on what product/feature/component is enabled since features may still work without some of the components. E.g. kubernetesstatecore can run on node agents without DCA and collect limited telemetry.

    I think handling clusterAgent.disabled shouldn't be solved on feature level, rather on DDA/DDAI where each DDAI can get a clear signal whether it owns the component, uses existing component or component doesn't exist at all.

    agagniere agagniere commented on Oct 16, 2026 15:07 UTC
    Author

    @levan-m So if I understand correctly, you would prefer a toggle to disable the cluster agent outside of override ? Works for me, which team shall own this change ?

    Reviewers
    Assignees
    agagniere agagniere
    Labels
    risk: low confidence: 81.4% 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: 71.5% (HIGH) · Higher = larger blast radius
    71.5%
    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: 81.4% · Lower = rushed or shallow review
    81.4%
    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: 13.3% · Safe to merge
    13.3%