Skip to content

(No-op) SA1019: Remove deprecated functions usage#2478

Merged
tbavelier merged 8 commits into
mainfrom
tbavelier/remove-deprecated-functions-usage-on-main
Apr 15, 2026
Merged

(No-op) SA1019: Remove deprecated functions usage#2478
tbavelier merged 8 commits into
mainfrom
tbavelier/remove-deprecated-functions-usage-on-main

Conversation

@tbavelier

Copy link
Copy Markdown
Member

What does this PR do?

  • Replaces all deprecated functions with the modern equivalent

Motivation

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

Tested the plugin manually, verified metrics forwarder is still working and is stopped on object removal

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)

@tbavelier
tbavelier requested a review from a team as a code owner January 9, 2026 09:42
@tbavelier tbavelier added enhancement New feature or request qa/skip-qa labels Jan 9, 2026
@codecov-commenter

codecov-commenter commented Jan 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 21.56863% with 40 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.03%. Comparing base (d09fcb3) to head (eed36b0).

Files with missing lines Patch % Lines
internal/controller/datadogmonitor/controller.go 35.29% 9 Missing and 2 partials ⚠️
cmd/kubectl-datadog/flare/flare.go 0.00% 10 Missing ⚠️
cmd/kubectl-datadog/agent/check/check.go 0.00% 5 Missing ⚠️
pkg/controller/utils/datadog/metrics_forwarder.go 0.00% 4 Missing ⚠️
cmd/check-operator/upgrade/upgrade.go 0.00% 2 Missing ⚠️
cmd/helpers/secrets/secrets.go 0.00% 2 Missing ⚠️
hack/generate-docs/generate-docs.go 0.00% 1 Missing ⚠️
...al/controller/datadogagent/component_reconciler.go 0.00% 0 Missing and 1 partial ⚠️
...controller/datadogagent/controller_reconcile_v2.go 50.00% 1 Missing ⚠️
...oller/datadogagentinternal/component_reconciler.go 0.00% 1 Missing ⚠️
... and 2 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2478      +/-   ##
==========================================
- Coverage   40.05%   40.03%   -0.03%     
==========================================
  Files         319      319              
  Lines       28052    28066      +14     
==========================================
- Hits        11237    11235       -2     
- Misses      15993    16008      +15     
- Partials      822      823       +1     
Flag Coverage Δ
unittests 40.03% <21.56%> (-0.03%) ⬇️

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

Files with missing lines Coverage Δ
internal/controller/datadogagent/merger/service.go 68.42% <100.00%> (ø)
internal/controller/datadogdashboard/controller.go 50.00% <100.00%> (ø)
...al/controller/datadoggenericresource/controller.go 53.17% <100.00%> (ø)
internal/controller/datadogslo/controller.go 59.88% <100.00%> (ø)
hack/generate-docs/generate-docs.go 0.00% <0.00%> (ø)
...al/controller/datadogagent/component_reconciler.go 71.71% <0.00%> (ø)
...controller/datadogagent/controller_reconcile_v2.go 61.00% <50.00%> (ø)
...oller/datadogagentinternal/component_reconciler.go 0.00% <0.00%> (ø)
...er/datadogagentinternal/controller_reconcile_v2.go 0.00% <0.00%> (ø)
pkg/controller/utils/shared_utils.go 0.00% <0.00%> (ø)
... and 6 more

... and 1 file 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 d09fcb3...eed36b0. 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 requested a review from a team as a code owner April 14, 2026 12:43
@datadog-datadog-prod-us1-2

datadog-datadog-prod-us1-2 Bot commented Apr 14, 2026

Copy link
Copy Markdown

❌ Code Coverage

Fix all issues with BitsAI

🛑 Gate Violations

🎯 1 Code Coverage issue detected

A Patch coverage percentage gate may be blocking this PR.

Patch coverage: 20.45% (threshold: 80.00%)

ℹ️ Info

🎯 Code Coverage (details)
Patch Coverage: 20.45%
Overall Coverage: 40.11% (-0.03%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: eed36b0 | Docs | Datadog PR Page | Was this helpful? React with 👍/👎 or give us feedback!

short-circuited on result.Requeue, effectively treating the
RequeueAfter result from tag injection as a local "tags were updated"
signal rather than generic reconcile flow control.

The SA1019 cleanup replaced that logic with !result.IsZero(), but that
broadened the condition and caused the controller to return early on any
non-zero result. In the required-tag path, that changed behavior by
routing control through a generic Result check instead of an explicit
"tags were updated" signal.

Refactor checkRequiredTags() to return (bool, error) instead:

true, nil when tags were added
false, err when the update failed
false, nil when nothing changed
This keeps the deprecation cleanup while making the tag-update path
intentional and avoiding misuse of IsZero() for local control flow.
@tbavelier
tbavelier merged commit 79c0824 into main Apr 15, 2026
37 of 38 checks passed
@tbavelier
tbavelier deleted the tbavelier/remove-deprecated-functions-usage-on-main branch April 15, 2026 06:46
nlchung added a commit that referenced this pull request Apr 17, 2026
The previous "revert unrelated changes" commit rolled main's post-#2478
state back to pre-#2478, undoing the deprecated-Requeue-field cleanup
and the checkRequiredTags (bool, error) signature. Restore main's
current state for those call sites so this PR is limited to the
finalizer reorganization.
nlchung added a commit that referenced this pull request Apr 17, 2026
* [CONTP-1335] organizing finalizers initial PR

* reverted bug fix

* Fix HandleFinalizer deletion-path return and remove redundant caller guards

HandleFinalizer was missing a return on the deletion path, causing
reconciliation to continue into create/update logic. Remove the
compensating GetDeletionTimestamp checks from all 5 callers, fix SLO
deleteResource closure capture, and improve finalizer test coverage.

Co-Authored-By: Claude Opus 4.6 (1M context) <[email protected]>

* added finalizer and error requeue periods

* fix: requeue after adding finalizer to match original controller behavior

HandleFinalizer was falling through after adding a finalizer instead of
requeuing, causing controllers to run create/update logic on the same
reconcile pass. This broke the datadogmonitor unsupported-type and
datadogslo create-failure test cases. Updated SLO tests to reconcile
twice (once for finalizer, once for actual logic).

* fix: use immediate requeue after adding finalizer for controllers that had Requeue:true

The old datadogagent, datadogagentinternal, datadogdashboard, and
datadoggenericresource controllers all used Requeue:true (immediate)
after adding a finalizer, while datadogmonitor/datadogslo used
RequeueAfter with a period. The shared HandleFinalizer now supports
both: pass 0 for immediate requeue, or a duration for delayed requeue.

This fixes the 34 integration test timeouts where the 60s requeue
delay exceeded the 10s test timeout.

* fix: use defaultErrRequeuePeriod for all controllers after adding finalizer

All migrated controllers now pass defaultErrRequeuePeriod (5s) as the
requeue period when adding a finalizer, consistent with the existing
datadogslo pattern. Removes the Requeue:true special case for zero
period from HandleFinalizer.

* refactor: simplify HandleFinalizer to use immediate requeue, revert unrelated changes

- Remove defaultRequeuePeriod param from NewFinalizer; HandleFinalizer
  now always uses immediate requeue (Requeue: true) after adding a
  finalizer or while waiting for deletion, matching the original behavior
  of most controllers.
- Revert result.IsZero() cleanup and checkRequiredTags signature refactor
  as they are out of scope for this ticket.

* fix: restore SA1019 cleanup from #2478 that was inadvertently reverted

The previous "revert unrelated changes" commit rolled main's post-#2478
state back to pre-#2478, undoing the deprecated-Requeue-field cleanup
and the checkRequiredTags (bool, error) signature. Restore main's
current state for those call sites so this PR is limited to the
finalizer reorganization.

* reinstated default requeue period and implemented deletion requeue period

* fixing naming inconsistency

---------

Co-authored-by: Claude Opus 4.6 (1M context) <[email protected]>
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.

3 participants