Set DD_DISCOVERY_ENABLED=false on the core Agent when service discovery is disabled #3807
All Vouch review confidence checks passed
Residual risk 0.20 = Change Risk (0.50) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.50 · 638 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
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.386
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3807"
general
weight: 0.35
tbavelier
What does this PR do?
When the service discovery feature resolves to disabled (
features.serviceDiscovery.enabled: false, or omitted with an Agent older than 7.78), the Operator now setsDD_DISCOVERY_ENABLED=falseon the node Agent instead of leaving it unset.Configurenow returns a configured-onlyRequiredComponentfor the Agent when the feature is disabled. It lists the core agent container and leavesIsRequiredunset, so the feature'sManagefunctions still run without requiring or adding any containers.ManageNodeAgentsetsDD_DISCOVERY_ENABLED=falseon theagentcontainer, thesystem-probecontainer and theinit-configinit container, which are the same targets as the enabled path. Thesystem-probecontainer only exists when another feature (such as NPM) requires it; otherwise the env var manager does nothing for it.ManageSingleContainerNodeAgentsets it on the unprivileged single agent container.override.nodeAgent.envis applied after features, so aDD_DISCOVERY_ENABLEDvalue set by the user still wins.Motivation
CONS-12086
Since Agent 7.79.0 (DataDog/datadog-agent#48000),
discovery.enableddefaults totrueon Linux in the system-probe config, and the core Agent reads it (isServiceDiscoveryEnabledincomp/core/workloadmeta/collectors/internal/process/process_collector.go). The Operator only ever setDD_DISCOVERY_ENABLED="true"when the feature was enabled. The only place it was hard-coded tofalsewas the cluster checks runner (internal/controller/datadogagent/component/clusterchecksrunner/default.go).When service discovery is disabled and there is no system-probe container, the core Agent falls back to
trueand starts theservice_discoveryprocess check. After the 5-minute startup grace period, it logs this error every minute:Reproduced with Agent 7.85.0 and
features.serviceDiscovery.enabled: false.There was a second gap: with service discovery disabled but NPM enabled, the
system-probecontainer had noDD_DISCOVERY_ENABLEDand also fell back totrue.This mirrors the companion Helm chart fix: https://github.com/DataDog/helm-charts/pull/3087
Additional Notes
FeatureTestSuitecase now expectsWantConfigure: true. It checksDD_DISCOVERY_ENABLED=falseonagent,system-probeandinit-config, and that no volumes, mounts or capabilities are added.Test_serviceDiscoveryFeature_ManageSingleContainerNodeAgent_Disabledcovers the single-container path.falseis harmless on Agent versions older than 7.79, which already default to disabled.Minimum Agent Versions
Are there minimum versions of the Datadog Agent and/or Cluster Agent required?
Agent: N/A (the bug shows up with Agent v7.79.0+, but the fix is safe on any version)
Describe your test plan
1. Deploy the Operator from this branch with Agent 7.79.0 or later (reproduced with 7.85.0).
2. Apply a
DatadogAgentwith service discovery disabled and no other feature that needs system-probe:3. Check that the node Agent DaemonSet has
DD_DISCOVERY_ENABLED=falseon theagentcontainer, for example:kubectl get ds <agent-daemonset> -o jsonpath='{.spec.template.spec.containers[?(@.name=="agent")].env[?(@.name=="DD_DISCOVERY_ENABLED")].value}'4. Wait about 5 minutes after the Agent pods start. Then confirm the
agentcontainer logs nofailed to get serviceserrors:kubectl logs <agent-pod> -c agent | grep "failed to get services"should return nothing.5. Optional: enable NPM with service discovery still disabled, and check that the
system-probecontainer also hasDD_DISCOVERY_ENABLED=false.6. Regression check: with
features.serviceDiscovery.enabled: true,DD_DISCOVERY_ENABLED=trueis still set and the system-probe container, volumes and capabilities are unchanged.Unit tests:
go test ./internal/controller/datadogagent/feature/servicediscovery/...andgo test ./internal/controller/datadogagent/... ./internal/controller/datadogagentinternal/... ./internal/controller/testutils/...pass locally.Checklist
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel[1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits
[CONS-12086]: https://datadoghq.atlassian.net/browse/CONS-12086?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ