Add the orphan management policy to Datadog resource controllers #3848
All Vouch review confidence checks passed
Residual risk 0.19 = Change Risk (0.48) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.48 · 507 lines diff across 6 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.373
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #3848"
general
weight: 0.35
gabedos
What does this PR do?
Adds the
datadoghq.com/management-policy: orphanannotation toDatadogGenericResource,DatadogMonitor,DatadogDashboardandDatadogSLO. On an annotated CR:Orphaned=Truecondition. The other status fields keep their last values.Orphanedevent.Implementation:
finalizer.NewOrphanFinalizer. That finalizer never deletes the Datadog object, so the annotation releases a CR even when the keys are missing or can't be decrypted. For DDGR it also doesn't need a handler forspec.type, and updates status directly (requeuing on conflict) so a conflict retry cannot clobber newer status.finalizer.WithOrphanPolicy(recorder, onOrphan)option, so theDatadogAgent/DatadogAgentInternalcleanup doesn't change. TheonOrphanhook and theOrphanedevent run only after the finalizer is removed, so a failed update doesn't repeat them.DatadogMonitorpasses a hook that unregisters its metrics forwarder, skips registering a forwarder on create for already-orphaned monitors (monitorMetricsForwarderPredicate), and does not report reconcile metrics while orphaned.DatadogMonitorandDatadogGenericResourcepre-create guards (fresh read from the API server viaapiReader) also skip creation when that copy is orphaned, in case the cache doesn't have the annotation yet.datadogResourcePredicate): annotations don't bumpmetadata.generation, soGenerationChangedPredicatealone misses them.docs/management_policy.md, linked from the cleanup sections of the four CRD docs.Motivation
First PR of the stack for CONTP-2281 (design: CONTP-2280 brief). It is the safe handoff that migrating a legacy CR to an adopting DDGR needs, and it fixes the race in today's workaround (remove the finalizer, then delete, while the controller re-adds it). It also pauses a single CR, for example on a passive cluster.
Stack:
1. This PR: orphan management policy
2. #3849:
spec.idon DDGR (adoption)3. #3850: blocking check against legacy CRs
4. #3851:
kubectl datadog monitor migrateAdditional Notes
orphanis recognized. Other values behave as if the annotation were absent.DatadogMonitorkeeps its lastActive/Errorconditions, as documented ("other status fields keep their last values").Minimum Agent Versions
N/A
Describe your test plan
On kind against a sandbox org (whole stack deployed): an annotated DatadogDashboard, DatadogSLO and DatadogGenericResource were deleted and their Datadog objects kept. Also a new DDGR was created with the annotation and no backend object was created. Verified logs, orphan state.
Checklist
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel[1]: https://docs.github.com/en/authentication/managing-commit-signature-verification/signing-commits
[CONTP-2281]: https://datadoghq.atlassian.net/browse/CONTP-2281?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ