← Back to Pull requests

Use raw manifest to create shared configs and dependencies #3559

Open
khewonc opened this pull request with 2245 lines diff across 39 files
View on GitHub
khewonc khewonc commented on Oct 06, 2026 14:52 UTC
Author

What does this PR do?

Uses the user provided manifest instead of a defaulted manifest to create shared configs and dependencies for profiles and ddas. Previously, we used the defaulted manifest, so we couldn't tell if a config was set by the user or defaulted. For profile overlays, this meant we'd favor a defaulted (but unset) config over a user-set profile config

Motivation

https://datadoghq.atlassian.net/browse/CONTP-2154

Additional Notes

Profiles now apply explicit SSI settings even when instrumentation.enabled is omitted, instead of ignoring them:
DDA

instrumentation:
  enabled: true
  languageDetection:
    enabled: true

Profile

instrumentation:
  languageDetection:
    enabled: false

Before: profile setting ignored

instrumentation:
  enabled: true
  languageDetection:
    enabled: true

After: profile setting overrides the DDA

instrumentation:
  enabled: true
  languageDetection:
    enabled: false

Minimum Agent Versions

Are there minimum versions of the Datadog Agent and/or Cluster Agent required?

Agent: vX.Y.Z
Cluster Agent: vX.Y.Z

Describe your test plan

1. Deploy operator with profiles enabled
2. Create a dda with admission controller, apm, and ssi enabled:

 features:
   admissionController:
     enabled: true
   apm:
     enabled: true
     instrumentation:
       enabled: true
       languageDetection:
         enabled: true

3. Create a profile with language detection disabled and apm host port 9126 enabled:
 features:
   apm:
     hostPortConfig:
       enabled: true
       hostPort: 9126
     instrumentation:
       languageDetection:
         enabled: false

4. Check that the dap is applied: kubectl get dap <dap> -o jsonpath='{.status.applied}{"\n"}' should be true
5. Check that language detection is disabled in default and profile ddais: kubectl get ddai <ddai> -o jsonpath='{.spec.features.apm.instrumentation.languageDetection.enabled}{"\n"}' should be false
6. Check the host ports: kubectl get ddai -o custom-columns='NAME:.metadata.name,APM_HOST_PORT:.spec.features.apm.hostPortConfig.hostPort'. The profile DDAI should show 9126; the default DDAI should show <none>

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: 2245 lines (+1739 / -506) across 39 files Reviewer: khewonc Review duration: 80051m
    All Vouch review confidence checks passed
    Residual risk 0.26 = Change Risk (0.96) × (1 − Review Confidence (0.73)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.96 · 2245 lines diff across 39 files
    0.96
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.68 · 4 substantive comment(s)
    0.68
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 50%
    72%
    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
    Self Review self_review
    0.140
    Sensitive Paths sensitive_paths
    0.096
    Mass File Touch mass_file_touch
    0.080
    Real PR Conversation Timeline
    6 items
    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Oct 06, 2026 14:53 UTC
    Bot

    <!-- codex-pull-request-review-summary -->

    Codex Review Summary

    This comment shows the latest Codex review activity on this pull request.

    | Review | Status | Commit | Review trigger |
    | --- | --- | --- | --- |
    | 📝 Code Review | ✅ Completed <relative-time datetime="2026-10-06T14:57:27.230297Z">2026-10-06T14:57:27.230297Z</relative-time> | a9c8914 | PR opened |

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Your team has set up Codex to 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" or "@codex security review".
  • Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

    </details>

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on code on Oct 06, 2026 14:57 UTC
    Code Review
    internal/controller/datadogagent/feature/apm/profile_overlay.go:1
    @@ -15,65 +15,108 @@ import (
     	"github.com/DataDog/datadog-operator/pkg/constants"
     )
     
    -func applyAPMProfileSharedConfigOverlay(dst, base *v2alpha1.DatadogAgentSpec, profileSpec *v2alpha1.DatadogAgentSpec) error {
    -	if err := applyProfileLocalAgentServicePort(dst, base, profileSpec); err != nil {
    +// applyAPMProfileSharedConfigOverlay checks explicit values in validationSpec
    +// and applies shared settings to defaultDDAISpec. Only the DDAI gets defaults.
    +func applyAPMProfileSharedConfigOverlay(validationSpec, defaultDDAISpec, originalDefaultDDAISpec, profileSpec *v2alpha1.DatadogAgentSpec) error {
    +	if profileSpec == nil || profileSpec.Features == nil || profileSpec.Features.APM == nil {
    +		return nil
    +	}
    +	profileAPM := profileSpec.Features.APM
    +	if err := mergeProfileLocalAgentServicePort(validationSpec, defaultDDAISpec, originalDefaultDDAISpec, profileAPM); err != nil {
     		return err
     	}
    -
    -	// Only profiles that explicitly enable SSI contribute shared Cluster Agent
    -	// config. SSI enabled=false is treated as "no shared overlay".
    -	profileSSI, ok := profileSSIOverlayConfig(profileSpec)
    -	if !ok {
    +	profileSSI := profileAPM.SingleStepInstrumentation
    +	if profileSSI == nil || !ptr.Deref(profileSSI.Enabled, false) {
     		return nil
     	}
    -
    -	if profileSpec.Features.APM.Enabled != nil && !ptr.Deref(profileSpec.Features.APM.Enabled, false) {
    +	if profileAPM.Enabled != nil && !ptr.Deref(profileAPM.Enabled, false) {
     		return fmt.Errorf("features.apm.enabled must be true or unset when features.apm.instrumentation.enabled is true")
     	}
    -	if err := validateSSISharedComponentPrerequisites(dst); err != nil {
    +	if err := validateSSISharedComponentPrerequisites(originalDefaultDDAISpec); err != nil {
     		return err
     	}
    -	if len(profileSSI.Targets) > 0 && !supportsInstrumentationTargets(dst) {
    +	if len(profileSSI.Targets) > 0 && !supportsInstrumentationTargets(originalDefaultDDAISpec) {
     		return fmt.Errorf("features.apm.instrumentation.targets requires Cluster Agent version >= %s", minInstrumentationTargetsVersion)
     	}
     
    -	dstSSI := baseSSIForProfileOverlay(dst)
    -	if err := mergeSSI(dstSSI, profileSSI); err != nil {
    +	rawSSI := baseSSIForProfileOverlay(validationSpec)
    +	ssi := baseSSIForProfileOverlay(defaultDDAISpec)
    +	if err := mergeSSI(rawSSI, ssi, profileSSI); err != nil {
     		return err
     	}
    -	dstSSI.Enabled = new(true)
    -	defaultLanguageDetection(dstSSI)
    -
    +	rawSSI.Enabled = new(true)
    +	ssi.Enabled = new(true)
     	return nil
     }
     
    -func applyProfileLocalAgentServicePort(dst, base, profileSpec *v2alpha1.DatadogAgentSpec) error {
    -	profilePort, ok := profileLocalAgentServicePort(profileSpec)
    -	if !ok {
    -		return nil
    +func sharedAPMConfig(spec *v2alpha1.DatadogAgentSpec) *v2alpha1.APMFeatureConfig {
    +	if spec.Features == nil {
    +		spec.Features = &v2alpha1.DatadogFeatures{}
     	}
    +	if spec.Features.APM == nil {
    +		spec.Features.APM = &v2alpha1.APMFeatureConfig{}
    +	}
    +	return spec.Features.APM
    +}
     
    -	existingPort, ok := existingLocalAgentServicePort(dst, base)
    -	if ok && existingPort != profilePort {
    -		return fmt.Errorf("local Agent Service port %q conflicts with existing port", constants.DefaultApmPortName)
    +// profileAPM is non-nil; the overlay entry point checks it once.
    +func mergeProfileLocalAgentServicePort(validationSpec, defaultDDAISpec, originalDefaultDDAISpec *v2alpha1.DatadogAgentSpec, profileAPM *v2alpha1.APMFeatureConfig) error {
    +	// Inherit APM enablement without changing the profile's explicit settings.
    +	var baseAPM *v2alpha1.APMFeatureConfig
    +	if originalDefaultDDAISpec != nil && originalDefaultDDAISpec.Features != nil {
    +		baseAPM = originalDefaultDDAISpec.Features.APM
    +	}
    +	effectiveAPM := *profileAPM
    +	if effectiveAPM.Enabled == nil && baseAPM != nil {
    +		effectiveAPM.Enabled = baseAPM.Enabled
     	}
    -	if ok {
    +	if !shouldEnableAPM(&effectiveAPM) {

    <sub><sub>!P2 Badge</sub></sub> Preserve SSI-derived APM enablement before inheriting the base

    When the base DDA explicitly disables APM but a profile leaves features.apm.enabled unset and enables instrumentation, assigning the base's false value here masks shouldEnableAPM's rule that enabled SSI implies enabled APM. Consequently the profile's Service port is not added to the validation/shared specs; two such profiles with different host ports are both marked applied, and manageDDADependenciesWithDDAI later fails the entire DDA reconciliation with a Service port conflict instead of rejecting only the conflicting profile. Only inherit the base value when the profile has no feature (such as SSI) that independently enables APM.

    Useful? React with 👍 / 👎.

    chatgpt-codex-connector[bot] chatgpt-codex-connector[bot] commented on Oct 06, 2026 14:57 UTC
    Reviewer

    💡 Codex Review

    Here are some automated review suggestions for this pull request.

    Reviewed commit: a9c8914e97

    <details> <summary>ℹ️ About Codex in GitHub</summary>
    <br/>

    Your team has set up Codex to 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 👍.

    Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

    </details>

    datadog-official[bot] datadog-official[bot] commented on Oct 06, 2026 15:18 UTC
    Bot

    <a target='_blank' href='https://app.datadoghq.com/ci/pipeline-executions?query=ci_level%3Ajob+%40ci.status%3Aerror+%40git.commit.sha%3Afac189cf7f2a933fbc6cbde92d0e7781db2dca48&referrer=pr-comment&start=1793913982000'><picture><source media="(prefers-color-scheme: dark)" srcset="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-error.svg"/><img src="https://static.datadoghq.com/static/images/pr_comments/software_delivery/badges_header/pipelines-error-light.svg" alt="Pipelines" align="center" /></picture></a> &nbsp;<a target='_blank' href='https://app.datadoghq.com/ci/code-coverage/github.com%2Fdatadog%2Fdatadog-operator/pull-requests/3559'><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>

    ❌ Errors

    Your PR has failed checks. Please review the issues below and take necessary action before merging.

    🚦 2 Pipeline jobs failed

    <blockquote>
    <div>

    <details open>
    <summary>DDCI - DataDog/datadog-operator | e2e_autoscaling</summary>

    <a href="https://app.datadoghq.com/ci/pull-request/Z2l0aHViLmNvbS9kYXRhZG9nL2RhdGFkb2ctb3BlcmF0b3IvMzU1OQ==?referrer=pr-comment&amp;buildId=AwAAAaGuGpiI5vm9agAAABhBYUd1R3BpSUFBQ3d3cXJTXzQtT1pfXzAAAAAkMDFhMWFlMjctNzU4MC00YmM1LWEzNmQtYWE1N2EwZDM4ZTZlAAAAAA&amp;ciFailurePanel=job">View more details</a> · <a href="https://mosaic.us1.ddbuild.io/change-request/repository/DataDog/datadog-operator/pull/3559/request/4528085301913716284?taskExecutionId=2220502710&amp;taskId=gitlab">View in DDCI</a>
    </details>

    <details open>
    <summary>DataDog/datadog-operator | e2e_autoscaling</summary>

    <a href="https://app.datadoghq.com/ci/pull-request/Z2l0aHViLmNvbS9kYXRhZG9nL2RhdGFkb2ctb3BlcmF0b3IvMzU1OQ==?referrer=pr-comment&amp;buildId=AwAAAaGuwIkAGmS07QAAABhBYUd1d0lrQUFBRGZISHZFNXZUZXVJYmQAAAAkMDFhMWFlYzAtZjFkOS00OTU4LWJhODYtNGExMGMzMTY3YmM4AAAF4Q&amp;ciFailurePanel=job">View more details</a> · <a href="https://gitlab.ddbuild.io/DataDog/datadog-operator/-/jobs/2221053698">View in GitLab</a>
    </details>
    </div>
    </blockquote>

    ℹ️ Info

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

    Useful? React with 👍 / 👎

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

    khewonc khewonc commented on code on Oct 06, 2026 15:19 UTC
    Code Review
    internal/controller/datadogagent/feature/apm/profile_overlay.go:1
    @@ -15,65 +15,108 @@ import (
     	"github.com/DataDog/datadog-operator/pkg/constants"
     )
     
    -func applyAPMProfileSharedConfigOverlay(dst, base *v2alpha1.DatadogAgentSpec, profileSpec *v2alpha1.DatadogAgentSpec) error {
    -	if err := applyProfileLocalAgentServicePort(dst, base, profileSpec); err != nil {
    +// applyAPMProfileSharedConfigOverlay checks explicit values in validationSpec
    +// and applies shared settings to defaultDDAISpec. Only the DDAI gets defaults.
    +func applyAPMProfileSharedConfigOverlay(validationSpec, defaultDDAISpec, originalDefaultDDAISpec, profileSpec *v2alpha1.DatadogAgentSpec) error {
    +	if profileSpec == nil || profileSpec.Features == nil || profileSpec.Features.APM == nil {
    +		return nil
    +	}
    +	profileAPM := profileSpec.Features.APM
    +	if err := mergeProfileLocalAgentServicePort(validationSpec, defaultDDAISpec, originalDefaultDDAISpec, profileAPM); err != nil {
     		return err
     	}
    -
    -	// Only profiles that explicitly enable SSI contribute shared Cluster Agent
    -	// config. SSI enabled=false is treated as "no shared overlay".
    -	profileSSI, ok := profileSSIOverlayConfig(profileSpec)
    -	if !ok {
    +	profileSSI := profileAPM.SingleStepInstrumentation
    +	if profileSSI == nil || !ptr.Deref(profileSSI.Enabled, false) {
     		return nil
     	}
    -
    -	if profileSpec.Features.APM.Enabled != nil && !ptr.Deref(profileSpec.Features.APM.Enabled, false) {
    +	if profileAPM.Enabled != nil && !ptr.Deref(profileAPM.Enabled, false) {
     		return fmt.Errorf("features.apm.enabled must be true or unset when features.apm.instrumentation.enabled is true")
     	}
    -	if err := validateSSISharedComponentPrerequisites(dst); err != nil {
    +	if err := validateSSISharedComponentPrerequisites(originalDefaultDDAISpec); err != nil {
     		return err
     	}
    -	if len(profileSSI.Targets) > 0 && !supportsInstrumentationTargets(dst) {
    +	if len(profileSSI.Targets) > 0 && !supportsInstrumentationTargets(originalDefaultDDAISpec) {
     		return fmt.Errorf("features.apm.instrumentation.targets requires Cluster Agent version >= %s", minInstrumentationTargetsVersion)
     	}
     
    -	dstSSI := baseSSIForProfileOverlay(dst)
    -	if err := mergeSSI(dstSSI, profileSSI); err != nil {
    +	rawSSI := baseSSIForProfileOverlay(validationSpec)
    +	ssi := baseSSIForProfileOverlay(defaultDDAISpec)
    +	if err := mergeSSI(rawSSI, ssi, profileSSI); err != nil {
     		return err
     	}
    -	dstSSI.Enabled = new(true)
    -	defaultLanguageDetection(dstSSI)
    -
    +	rawSSI.Enabled = new(true)
    +	ssi.Enabled = new(true)
     	return nil
     }
     
    -func applyProfileLocalAgentServicePort(dst, base, profileSpec *v2alpha1.DatadogAgentSpec) error {
    -	profilePort, ok := profileLocalAgentServicePort(profileSpec)
    -	if !ok {
    -		return nil
    +func sharedAPMConfig(spec *v2alpha1.DatadogAgentSpec) *v2alpha1.APMFeatureConfig {
    +	if spec.Features == nil {
    +		spec.Features = &v2alpha1.DatadogFeatures{}
     	}
    +	if spec.Features.APM == nil {
    +		spec.Features.APM = &v2alpha1.APMFeatureConfig{}
    +	}
    +	return spec.Features.APM
    +}
     
    -	existingPort, ok := existingLocalAgentServicePort(dst, base)
    -	if ok && existingPort != profilePort {
    -		return fmt.Errorf("local Agent Service port %q conflicts with existing port", constants.DefaultApmPortName)
    +// profileAPM is non-nil; the overlay entry point checks it once.
    +func mergeProfileLocalAgentServicePort(validationSpec, defaultDDAISpec, originalDefaultDDAISpec *v2alpha1.DatadogAgentSpec, profileAPM *v2alpha1.APMFeatureConfig) error {
    +	// Inherit APM enablement without changing the profile's explicit settings.
    +	var baseAPM *v2alpha1.APMFeatureConfig
    +	if originalDefaultDDAISpec != nil && originalDefaultDDAISpec.Features != nil {
    +		baseAPM = originalDefaultDDAISpec.Features.APM
    +	}
    +	effectiveAPM := *profileAPM
    +	if effectiveAPM.Enabled == nil && baseAPM != nil {
    +		effectiveAPM.Enabled = baseAPM.Enabled
     	}
    -	if ok {
    +	if !shouldEnableAPM(&effectiveAPM) {

    1f176d6f637bb625b934e7dc86d2f881ba474eb9

    Reviewers
    Assignees
    khewonc khewonc
    Labels
    risk: low confidence: 72.8% reviewed sensitive_module
    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: 96% (HIGH) · Higher = larger blast radius
    96%
    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: 72.8% · Lower = rushed or shallow review
    72.8%
    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: 26.1% · Safe to merge
    26.1%