Skip to content

Conversation

@khewonc
Copy link
Contributor

@khewonc khewonc commented Dec 1, 2025

What does this PR do?

Add create strategy to DDAIs for parity. The create strategy code for DDAs can be deleted later with reconcileV2

Motivation

What inspired you to submit this pull request?

Additional Notes

Anything else we should know when reviewing?

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

In a cluster with multiple nodes:

  • Enable profiles, DDAIs, and create strategy in the operator pod
  • Create a DDA
  • Create a DAP that applies to multiple nodes and ensure the rollout speed is slow enough that you can check that pods are created according to the rollout strategy. For example. this config in the DAP should cause pods to be replaced one by one:
  config:
    override:
      nodeAgent:
        updateStrategy:
          type: RollingUpdate
          rollingUpdate:
            maxUnavailable: 1
  • While it's rolling out, check that the DAP status is being updated with kubectl describe dap <name>. The status can be:
  Create Strategy:
    Max Unavailable:  <maxUnavailable> # should match maxUnavailable from a manifest (or use default value)
    Nodes Labeled:    <number of labeled nodes> # the number of nodes labeled with the profile label "agent.datadoghq.com/datadogagentprofile"
    Pods Ready:       <number of ready pods> # the number of pods whose status is ready
    Status:           Waiting # create strategy status can be waiting, in progress, or completed

You can have things like:

# waiting for one pod to become ready before labeling the next node
  Create Strategy:
    Max Unavailable:  1
    Nodes Labeled:    1
    Pods Ready:       0
    Status:           Waiting
# rollout is completed
  Create Strategy:
    Max Unavailable:  1
    Nodes Labeled:    16
    Pods Ready:       16
    Status:           Completed

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

@khewonc khewonc added this to the v1.22.0 milestone Dec 1, 2025
@khewonc khewonc requested a review from a team as a code owner December 1, 2025 23:35
@khewonc khewonc added the enhancement New feature or request label Dec 1, 2025
@codecov-commenter
Copy link

codecov-commenter commented Dec 4, 2025

Codecov Report

❌ Patch coverage is 57.39130% with 49 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.07%. Comparing base (7ed6f60) to head (09cb5c0).

Files with missing lines Patch % Lines
pkg/agentprofile/agent_profile.go 65.82% 20 Missing and 7 partials ⚠️
internal/controller/datadogagent/profile.go 26.66% 21 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2367      +/-   ##
==========================================
+ Coverage   37.01%   37.07%   +0.05%     
==========================================
  Files         288      288              
  Lines       24453    24553     +100     
==========================================
+ Hits         9051     9102      +51     
- Misses      14698    14739      +41     
- Partials      704      712       +8     
Flag Coverage Δ
unittests 37.07% <57.39%> (+0.05%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...controller/datadogagent/controller_reconcile_v2.go 58.28% <100.00%> (+1.14%) ⬆️
internal/controller/datadogagent/profile.go 73.42% <26.66%> (-13.02%) ⬇️
pkg/agentprofile/agent_profile.go 72.91% <65.82%> (-2.57%) ⬇️

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7ed6f60...09cb5c0. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@tbavelier tbavelier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small: we do not use the lastTransition field in DDAI version unlike in DDA:

if profile.Status.CreateStrategy.Status != newStatus {
profile.Status.CreateStrategy.LastTransition = &now
}

created #2407 (check first commit "only", 2nd is test) as a suggestion but can be dropped

}

func (r *Reconciler) getProfileDaemonSet(ctx context.Context, profile *v1alpha1.DatadogAgentProfile, dsName types.NamespacedName) (*appsv1.DaemonSet, error) {
validDaemonSetNames, _ := r.getValidDaemonSetNames(dsName.Name, map[string]struct{}{}, []v1alpha1.DatadogAgentProfile{*profile}, true)
Copy link
Member

@tbavelier tbavelier Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
validDaemonSetNames, _ := r.getValidDaemonSetNames(dsName.Name, map[string]struct{}{}, []v1alpha1.DatadogAgentProfile{*profile}, true)
// TODO: introspection - we pass an empty provider list
validDaemonSetNames, _ := r.getValidDaemonSetNames(dsName.Name, map[string]struct{}{}, []v1alpha1.DatadogAgentProfile{*profile}, true)

Comment so when we start supporting introspection, so we don't forget ?

Copy link
Member

@tbavelier tbavelier Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: the spacing might be off, I manually added spaces when creating this suggestion, I wouldn't commit it from github UI

Comment on lines +725 to +730
info := csInfo[profileNSName]
if info == nil {
return false
}

return true
Copy link
Member

@tbavelier tbavelier Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
info := csInfo[profileNSName]
if info == nil {
return false
}
return true
return csInfo[profileNSName] != nil

nit: little simplification ?

@tbavelier tbavelier merged commit 4273393 into main Dec 17, 2025
33 checks passed
@tbavelier tbavelier deleted the khewonc/create-strategy-ddai branch December 17, 2025 16:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants