Skip to content

Create controller revisions for DDAs#2767

Open
khewonc wants to merge 2 commits intomainfrom
khewonc/create-controllerrevisions
Open

Create controller revisions for DDAs#2767
khewonc wants to merge 2 commits intomainfrom
khewonc/create-controllerrevisions

Conversation

@khewonc
Copy link
Collaborator

@khewonc khewonc commented Mar 17, 2026

What does this PR do?

Creates controller revisions for DDAs

Motivation

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

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

  • Enable operator flag: createControllerRevisions and set to true
  • Deploy a DDA manifest and check that a controller revision was created: kubectl get controllerrevisions. It should also be reflected in DDA status
  • Update the DDA spec/annotations and check that a new controller revision is created with revision 2 and the old controllerrevision still exists
  • Revert your change and check that the old controllerrevision is now the currentRevision (in DDA status) and revision 3. The second controller revision is still revision 2
  • Make a new change to the DDA spec/annotations. Check that a new controller revision is created with revision 4. Revision 2 should be deleted

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)

@khewonc khewonc added this to the v1.26.0 milestone Mar 17, 2026
@khewonc khewonc requested a review from a team March 17, 2026 16:29
@khewonc khewonc added the enhancement New feature or request label Mar 17, 2026
@khewonc khewonc requested review from a team as code owners March 17, 2026 16:29
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 11f0fd5c58

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +75 to +79
if r.options.CreateControllerRevisions {
if err := r.manageRevision(ctx, instance, newDDAStatus); err != nil {
return r.updateStatusIfNeededV2(logger, instance, ddaStatusCopy, result, err, now)
}
}

Choose a reason for hiding this comment

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

P2 Badge Create revisions in both reconcile modes when flag is on

With createControllerRevisions=true, revisions are only managed inside reconcileInstanceV3, but internalReconcileV2 still routes to reconcileInstanceV2 whenever DatadogAgentInternalEnabled is false. In that supported configuration, the new flag silently does nothing, so no ControllerRevision snapshots are created even though the CLI flag explicitly says it applies to DDA spec changes.

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Changed in 86357ab by enforcing DatadogAgentInternalEnabled=true in order for createControllerRevisions to be true

Comment on lines +60 to +63
if err := r.client.List(ctx, revList,
client.InNamespace(instance.GetNamespace()),
client.MatchingLabels{apicommon.DatadogAgentNameLabelKey: instance.GetName()},
); err != nil {

Choose a reason for hiding this comment

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

P2 Badge Scope revision listing to the current DDA owner UID

Revision selection and GC are driven from listRevisions, which currently matches only namespace plus the DDA-name label. If a DDA is deleted/recreated with the same name (or another revision is mislabeled), this controller can reuse or delete ControllerRevisions not owned by the current object UID, causing currentRevision/previousRevision to reference foreign history and making rollback state unstable. Filtering by controller owner reference (UID/controller=true) is needed here.

Useful? React with 👍 / 👎.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Addressed in 86357ab

@codecov-commenter
Copy link

codecov-commenter commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 66.90141% with 47 lines in your changes missing coverage. Please review.
✅ Project coverage is 38.57%. Comparing base (40eb5c8) to head (86357ab).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
internal/controller/datadogagent/revision.go 76.92% 14 Missing and 10 partials ⚠️
pkg/controllerrevisions/controller_history.go 42.30% 15 Missing ⚠️
...controller/datadogagent/controller_reconcile_v2.go 0.00% 2 Missing and 1 partial ⚠️
cmd/main.go 0.00% 2 Missing ⚠️
...ler/datadogagent/controller_reconcile_v2_common.go 33.33% 1 Missing and 1 partial ⚠️
internal/controller/datadogagent_controller.go 0.00% 0 Missing and 1 partial ⚠️

❌ Your patch status has failed because the patch coverage (66.90%) is below the target coverage (80.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2767      +/-   ##
==========================================
- Coverage   38.80%   38.57%   -0.23%     
==========================================
  Files         309      311       +2     
  Lines       26750    27448     +698     
==========================================
+ Hits        10379    10589     +210     
- Misses      15592    16069     +477     
- Partials      779      790      +11     
Flag Coverage Δ
unittests 38.57% <66.90%> (-0.23%) ⬇️

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

Files with missing lines Coverage Δ
internal/controller/datadogagent/controller.go 92.85% <ø> (ø)
...er/datadogagent/controller_reconcile_v2_helpers.go 65.17% <100.00%> (+0.35%) ⬆️
internal/controller/setup.go 35.91% <100.00%> (+0.35%) ⬆️
internal/controller/datadogagent_controller.go 66.66% <0.00%> (ø)
cmd/main.go 6.66% <0.00%> (-0.05%) ⬇️
...ler/datadogagent/controller_reconcile_v2_common.go 32.97% <33.33%> (+<0.01%) ⬆️
...controller/datadogagent/controller_reconcile_v2.go 59.48% <0.00%> (-0.93%) ⬇️
pkg/controllerrevisions/controller_history.go 42.30% <42.30%> (ø)
internal/controller/datadogagent/revision.go 76.92% <76.92%> (ø)

... and 3 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 40eb5c8...86357ab. Read the comment docs.

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

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