← Back to Pull requests

Set DD_DISCOVERY_ENABLED=false on the core Agent when service discovery is disabled #3807

Closed
unknown closed this pull request without merging on Nov 18, 2026 15:18 UTC
View on GitHub
unknown unknown commented on Nov 17, 2026 17:35 UTC
Author

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 sets DD_DISCOVERY_ENABLED=false on the node Agent instead of leaving it unset.

  • Configure now returns a configured-only RequiredComponent for the Agent when the feature is disabled. It lists the core agent container and leaves IsRequired unset, so the feature's Manage functions still run without requiring or adding any containers.

  • ManageNodeAgent sets DD_DISCOVERY_ENABLED=false on the agent container, the system-probe container and the init-config init container, which are the same targets as the enabled path. The system-probe container only exists when another feature (such as NPM) requires it; otherwise the env var manager does nothing for it.

  • ManageSingleContainerNodeAgent sets it on the unprivileged single agent container.

  • The disabled path adds no volumes, mounts, capabilities or annotations.

  • override.nodeAgent.env is applied after features, so a DD_DISCOVERY_ENABLED value set by the user still wins.
  • Motivation

    CONS-12086

    Since Agent 7.79.0 (DataDog/datadog-agent#48000), discovery.enabled defaults to true on Linux in the system-probe config, and the core Agent reads it (isServiceDiscoveryEnabled in comp/core/workloadmeta/collectors/internal/process/process_collector.go). The Operator only ever set DD_DISCOVERY_ENABLED="true" when the feature was enabled. The only place it was hard-coded to false was 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 true and starts the service_discovery process check. After the 5-minute startup grace period, it logs this error every minute:

    handleServiceDiscoveryRequestError | failed to get services: ... dial unix /opt/datadog-agent/run/sysprobe.sock: connect: no such file or directory
    

    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-probe container had no DD_DISCOVERY_ENABLED and also fell back to true.

    This mirrors the companion Helm chart fix: https://github.com/DataDog/helm-charts/pull/3087

    Additional Notes

  • The "service discovery not enabled" FeatureTestSuite case now expects WantConfigure: true. It checks DD_DISCOVERY_ENABLED=false on agent, system-probe and init-config, and that no volumes, mounts or capabilities are added.

  • The new Test_serviceDiscoveryFeature_ManageSingleContainerNodeAgent_Disabled covers the single-container path.

  • Setting the env var to false is 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)

  • Cluster Agent: N/A
  • 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 DatadogAgent with service discovery disabled and no other feature that needs system-probe:

       spec:
         features:
           serviceDiscovery:
             enabled: false
       

    3. Check that the node Agent DaemonSet has DD_DISCOVERY_ENABLED=false on the agent container, 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 agent container logs no failed to get services errors: 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-probe container also has DD_DISCOVERY_ENABLED=false.
    6. Regression check: with features.serviceDiscovery.enabled: true, DD_DISCOVERY_ENABLED=true is still set and the system-probe container, volumes and capabilities are unchanged.

    Unit tests: go test ./internal/controller/datadogagent/feature/servicediscovery/... and go test ./internal/controller/datadogagent/... ./internal/controller/datadogagentinternal/... ./internal/controller/testutils/... pass locally.

    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

    [CONS-12086]: https://datadoghq.atlassian.net/browse/CONS-12086?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

    Diff: 638 lines (+478 / -160) across 7 files Reviewer: tbavelier Review duration: 1302m
    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
    0.50
    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.386
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3807"
    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: 50.4% (MEDIUM) · Higher = larger blast radius
    50.4%
    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: 19.9% · Safe to merge
    19.9%