[CONTP-1589] Add DDGR force sync period configuration#3043
Merged
Conversation
|
🎯 Code Coverage (details) 🔗 Commit SHA: efc450d | Docs | Datadog PR Page | Give us feedback! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3043 +/- ##
==========================================
+ Coverage 42.24% 42.36% +0.12%
==========================================
Files 337 337
Lines 28951 28964 +13
==========================================
+ Hits 12230 12272 +42
+ Misses 15916 15887 -29
Partials 805 805
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
gabedos
reviewed
May 26, 2026
gabedos
approved these changes
May 26, 2026
tbavelier
force-pushed
the
tbavelier/contp-1589
branch
from
May 26, 2026 15:56
f2efadb to
4cfe765
Compare
jeff-morgan-dd
approved these changes
May 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Adds
DD_GENERIC_RESOURCE_FORCE_SYNC_PERIODto configure theDatadogGenericResourceforce-sync interval, matching the existing monitor/dashboard/SLO behavior. The value is resolved once when the DDGR controller starts, logged at info level, and reused during reconciliation.The configured value must be at least one minute. Non-integer values,
0, and negative values are rejected once during controller startup and fall back to the default 60-minute force-sync period.Also documents DDGR force sync and the existing DDGR namespace watch environment variable.
Motivation
DatadogGenericResourcealready force-syncs remote resources every 60 minutes, but unlike related Datadog resource controllers, the interval was not configurable. This makes DDGR behavior easier to tune and easier to validate when remote resources drift from Kubernetes source of truth.Rejecting values below one minute avoids surprising behavior where
0or negative durations would force an update on every reconciliation loop.Additional Notes
DD_GENERIC_RESOURCE_WATCH_NAMESPACEalready existed and falls back toWATCH_NAMESPACE; this PR only documents that behavior.The reconcile tests construct the DDGR reconciler through
NewReconcilerand then override the resource handlers with mocks, so the production force-sync initialization path is covered without calling real Datadog APIs.Minimum Agent Versions
Are there minimum versions of the Datadog Agent and/or Cluster Agent required?
Describe your test plan
Automated validation:
go test -count=1 ./internal/controller/datadoggenericresourceThe tests cover valid force-sync configuration, invalid string values,
0, negative values, and an elapsed force-sync period triggering a remote update.Manual QA:
Start the operator with the DDGR controller enabled and an invalid force-sync period:
Verify the operator logs contain this error once during controller startup:
{"level":"ERROR","logger":"controllers.DatadogGenericResource","msg":"Invalid value for generic resource force sync period. Defaulting to 60 minutes.","error":"strconv.Atoi: parsing \"abc\": invalid syntax"}Restart the operator with a valid five-minute force-sync period:
Verify the operator logs contain this info log during controller startup:
{"level":"INFO","logger":"controllers.DatadogGenericResource","msg":"Setting generic resource force sync period","minutes":5}Apply the notebook DDGR sample:
Wait for the resource to be created and record the Datadog notebook ID:
kubectl get datadoggenericresource ddgr-notebook-sample -o jsonpath='{.status.id}'In the Datadog UI, open that notebook and make a visible edit, for example change the notebook name from
Example-NotebooktoExample-Notebook edited from UI.Wait at least five minutes, then verify the operator force-sync restored the notebook to the Kubernetes spec from
examples/datadoggenericresource/notebook-sample.yaml, including the original notebook nameExample-Notebook.Clean up the sample resource:
Checklist
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel