Skip to content

Conversation

@levan-m
Copy link
Contributor

@levan-m levan-m commented Dec 5, 2025

What does this PR do?

  • 6c855b1 resolves some seemingly accidental differences: feature error handling; passing ctx; introspection provider; error handling in cleanupV2ClusterChecksRunner. Mostly following DCA pattern in most cases. Also adds a test to cover these changes up front.
  • 80db14a moved cleanupOldCCR** function to file where it's used. Changed some log lines, variable names.
  • 619d4e0 pulled some of the functions, variable so they can be parametrized later.
  • bb24086 moved status cleanup inside component cleanup which was case with CCR, not DCA. This simplifies code but seems reasonable as we want to clear status only when component is cleaned up not before that.
  • 043a3cc move custom logic outside and added no-op function where necessary. reconcile and cleanup should be same, only using different functions which probably can be parametrized or extracted in interface - which would be next step.
  • 77e27a5 fixed function name and uncommented tests.

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

Write there any instructions and details you may have to test your PR.

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

@codecov-commenter
Copy link

codecov-commenter commented Dec 5, 2025

Codecov Report

❌ Patch coverage is 74.66667% with 38 lines in your changes missing coverage. Please review.
✅ Project coverage is 37.33%. Comparing base (34cf6c8) to head (77e27a5).
⚠️ Report is 3 commits behind head on main.

Files with missing lines Patch % Lines
...ontroller/datadogagent/controller_reconcile_ccr.go 76.56% 9 Missing and 6 partials ⚠️
...ontroller/datadogagent/controller_reconcile_dca.go 80.00% 4 Missing and 5 partials ⚠️
...er/datadogagent/controller_reconcile_v2_helpers.go 74.28% 4 Missing and 5 partials ⚠️
pkg/testutils/builder.go 0.00% 5 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2380      +/-   ##
==========================================
+ Coverage   36.97%   37.33%   +0.36%     
==========================================
  Files         287      287              
  Lines       24257    24664     +407     
==========================================
+ Hits         8968     9208     +240     
- Misses      14590    14750     +160     
- Partials      699      706       +7     
Flag Coverage Δ
unittests 37.33% <74.66%> (+0.36%) ⬆️

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 57.14% <100.00%> (ø)
pkg/testutils/builder.go 0.00% <0.00%> (ø)
...ontroller/datadogagent/controller_reconcile_dca.go 72.94% <80.00%> (+24.13%) ⬆️
...er/datadogagent/controller_reconcile_v2_helpers.go 60.12% <74.28%> (+4.30%) ⬆️
...ontroller/datadogagent/controller_reconcile_ccr.go 81.92% <76.56%> (+16.13%) ⬆️

... and 6 files with indirect coverage changes


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 34cf6c8...77e27a5. Read the comment docs.

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

@tbavelier tbavelier added this to the v1.22.0 milestone Dec 11, 2025
existingDeployment := &appsv1.Deployment{}
if err := r.client.Get(ctx, nsName, existingDeployment); err != nil {
if errors.IsNotFound(err) {
deleteStatusWithClusterChecksRunner(newStatus, common.ClusterChecksRunnerReconcileConditionType, setClusterChecksRunnerStatus)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
deleteStatusWithClusterChecksRunner(newStatus, common.ClusterChecksRunnerReconcileConditionType, setClusterChecksRunnerStatus)
deleteStatusV2WithClusterAgent(newStatus, common.ClusterAgentReconcileConditionType, setClusterAgentStatus)

This should be DCA I believe ? Not sure how we can enter this condition tho to verify

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Correct thanks for catching updated 77e27a5.

Copy link
Member

Choose a reason for hiding this comment

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

I believe it should also be common.ClusterAgentReconcileConditionType as the argument

Comment on lines +309 to +319
// getDeploymentNameFromCCR returns the expected CCR deployment name based on
// the DDA name and clusterChecksRunner name override
func getDeploymentNameFromCCR(dda *datadoghqv2alpha1.DatadogAgent) string {
deploymentName := clusterchecksrunner.GetClusterChecksRunnerName(dda)
if componentOverride, ok := dda.Spec.Override[datadoghqv2alpha1.ClusterChecksRunnerComponentName]; ok {
if componentOverride.Name != nil && *componentOverride.Name != "" {
deploymentName = *componentOverride.Name
}
}
return deploymentName
}
Copy link
Member

Choose a reason for hiding this comment

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

@ Timothée: common.GetDeploymentNameFromDatadogAgent gets DCA and does the same thing as this for CCR, only change is component + GetClusterAgentName vs GetClusterChecksRunnerName -> getComponentDeployNameFromDDA(ddaObject, ddaSpec, componentName) + getComponentName(dda, component)

@levan-m levan-m removed this from the v1.22.0 milestone Dec 15, 2025
levan-m added a commit that referenced this pull request Dec 26, 2025
@levan-m levan-m mentioned this pull request Dec 26, 2025
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants