Repository navigation
Description
Friction
The app-of-apps cluster re-applies Application k8s-monitoring every five minutes, around the clock, and stays OutOfSync most of the time (known K3). Each apply strips the two pre-delete finalizers that Argo CD adds because the k8s-monitoring chart ships a PreDelete hook; Argo CD then adds them back. cluster's sync status can no longer be trusted to show real drift, and for up to about 2m15s of every cycle k8s-monitoring has no pre-delete finalizer, so deleting it in that window skips the chart's clean-up Job and leaves resources hanging in Terminating.
Evidence
Live, read-only, 2026-10-17 (Argo CD v3.5.3; main = 3dd7fa6):
- argocd-application-controller-0 logged "Applying resource Application/k8s-monitoring" 110 times in about 9h35m since its 12:27Z restart, 12 times an hour (at :x0:19 and :x5:19); every other child Application was applied once. The API server warning "metadata.finalizers: "pre-delete-finalizer.argocd.argoproj.io": prefer a domain-qualified finalizer name" appears after each apply (107 times).
- Events on
clustercycle: "Initiated automated sync", "Partial sync operation ... succeeded", Synced, then OutOfSync 0s to 2m15s later. Only Application/k8s-monitoring is OutOfSync. - Sampling Application
argocd/k8s-monitoringevery 30s: at 22:01:47Z onlyresources-finalizer.argocd.argoproj.io; at 22:02:18Z alsopre-delete-finalizer.argocd.argoproj.ioandpre-delete-finalizer.argocd.argoproj.io/cleanup. - The
argocd.argoproj.io/hydrateannotation is not the cause: 21 of 23 Applications carry it and only k8s-monitoring drifts. - Deployment
monitoring/k8s-monitoring-alloy-operatorcarriesk8s.grafana.com/finalizer, which only the chart's pre-delete Job removes; Alloy CRsk8s-monitoring-alloy-{logs,metrics,singleton}carryhelm.sdk.operatorframework.io/uninstall-release. cluster'sstatus.historystill ends at id 13 (3dd7fa6): self-heal partial syncs do not add history.
Repo and source:
k8s/argocd/bootstrap/cluster.yaml:20-32ignores only/spec/source/kustomizeondevopsandingress, withRespectIgnoreDifferences=trueat:37-38.k8s/argocd/apps/k8s-monitoring.yaml:6-7lists only the resources finalizer.- Chart k8s-monitoring 4.5.2
templates/hooks/pre-delete_remove-alloy-and-finalizer.yamlships the Job and its RBAC ashelm.sh/hook: pre-delete, which Argo CD maps to PreDelete (controller/hook.go:33-35). - Argo CD v3.5.3 controller/appcontroller.go:1974-1986 adds both pre-delete finalizers when rendered manifests contain PreDelete hooks;
:1323runs PreDelete hooks only if the finalizer is present; the re-add is skipped once a deletionTimestamp is set (comment at:1973). tests/test_k8s_argocd_apps.py(around 395-417,test_the_app_of_apps_keeps_the_hosts_deploy_stack_sets_on_the_homelab_applications) assertsignoreDifferencesequals exactly the two kustomize entries.docs/agent/tasks/task-913-deploy-stack-applies-the-monitoring-perimeter.md:65has a pending check that this hook Job completes on removal.
Remedy
- Tests first: extend the test above to expect the new entry, and add a test that the jq expression selects
pre-delete-finalizer.argocd.argoproj.io,pre-delete-finalizer.argocd.argoproj.io/cleanupand the matching post-delete names, and does not selectresources-finalizer.argocd.argoproj.io(evaluate it with a jq library already available, or assert the exact expression string if none is). k8s/argocd/bootstrap/cluster.yaml: after the two kustomize entries, add one entry for every child Application:
group: argoproj.io,kind: Application,jqPathExpressions: ['.metadata.finalizers[] | select(startswith("pre-delete-finalizer.argocd.argoproj.io") or startswith("post-delete-finalizer.argocd.argoproj.io"))'], with a comment citing Argo CD's PreDelete finalizers. KeepRespectIgnoreDifferences=true; for a CRD, Argo CD then carries the live finalizers into the applied object.- Do not ignore
/metadata/finalizerswholesale (git would stop enforcing the resources finalizer), and do not hard-code the pre-delete finalizers ink8s-monitoring.yaml(Argo CD removes them itself when a chart drops its hook, which would loop the other way). changelog.d/<issue>.mdunder### Fixed.
Verification after the merge: kubectl -n argocd get events --field-selector involvedObject.name=cluster shows no "Initiated automated sync" every five minutes, cluster stays Synced, and k8s-monitoring keeps all three finalizers.
Priority: P2. Severity medium: nothing is broken today, but removal is racy and the root app's status hides drift.
Proposed design
Problem statement
The app-of-apps 'cluster' re-applies the Application 'k8s-monitoring' every five minutes, causing Argo CD to repeatedly strip and re-add pre-delete finalizers. This leads to constant OutOfSync status for k8s-monitoring, hiding real drift and creating a race condition during deletion where resources may be left in Terminating state.
Acceptance criteria
- Criterion 1: The cluster app-of-apps no longer repeatedly applies the k8s-monitoring Application
Verification: Verify that kubectl -n argocd get events --field-selector involvedObject.name=cluster shows no 'Initiated automated sync' every five minutes - Criterion 2: The k8s-monitoring Application maintains all three finalizers (resources-finalizer.argocd.argoproj.io, pre-delete-finalizer.argocd.argoproj.io, and pre-delete-finalizer.argocd.argoproj.io/cleanup) consistently
Verification: Verify that kubectl -n argocd get application k8s-monitoring -o jsonpath='{.metadata.finalizers}' shows all three finalizers present - Criterion 3: The cluster Application stays Synced instead of constantly going OutOfSync for k8s-monitoring
Verification: Verify that the cluster Application status remains Synced over a period of time
Key questions
- What specific finalizers are being stripped and re-added by Argo CD during the sync process?: The pre-delete finalizers 'pre-delete-finalizer.argocd.argoproj.io' and 'pre-delete-finalizer.argocd.argoproj.io/cleanup' are stripped and re-added when Argo CD applies the k8s-monitoring Application manifest. [sources: k8s/argocd/bootstrap/cluster.yaml:20-32]
- What is the current structure of ignoreDifferences in cluster.yaml?: The current ignoreDifferences section only ignores /spec/source/kustomize for devops and ingress Applications, with RespectIgnoreDifferences=true at line 37-38. [sources: k8s/argocd/bootstrap/cluster.yaml:20-32]
- What is the current finalizer configuration in k8s-monitoring.yaml?: The k8s-monitoring.yaml currently lists only the resources-finalizer.argocd.argoproj.io finalizer. [sources: k8s/argocd/apps/k8s-monitoring.yaml:6-7]
- What test verifies the current ignoreDifferences behavior?: The test test_the_app_of_apps_keeps_the_hosts_deploy_stack_sets_on_the_homelab_applications in tests/test_k8s_argocd_apps.py asserts that ignoreDifferences equals exactly the two kustomize entries. [sources: tests/test_k8s_argocd_apps.py:395-417]
- Should we extend the existing test to verify the new finalizer behavior?: Yes, we should extend the test to expect the new entry for pre-delete finalizers and add a test that verifies the jq expression selects the correct pre-delete and post-delete finalizers. (proposed)
- Should we modify the ignoreDifferences in cluster.yaml to include pre-delete finalizers?: Yes, we should add entries for pre-delete and post-delete finalizers in cluster.yaml's ignoreDifferences section to prevent the constant stripping and re-adding. (proposed)
- Should we continue ignoring /metadata/finalizers wholesale?: No, we should not ignore /metadata/finalizers wholesale as this would stop enforcing the resources finalizer and hard-code pre-delete finalizers that may change. (proposed)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 18, 2026
Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.
The candidate describes a bug where Argo CD's pre-delete finalizers are being stripped from child applications, causing resync issues.This bug affects the reliability and correctness of application deletion in the cluster, causing resources to hang in Terminating state.Fixing this ensures proper cleanup of resources during application deletion, which is critical for system stability and data integrity.Requires modifying the app-of-apps configuration and updating tests to ensure finalizers are respected during sync operations.dan-petty commentedon Oct 18, 2026
Status set to Ready at 25e2cda (see proposed design in issue body).
fix(argocd): ignore pre- and post-delete finalizers on child apps (#1674
dan-petty commentedon Oct 20, 2026
What changed
#1713, merged into
release/v0.2.37as 8bdca6e.6 file(s) changed.
How it was verified
Check runs at 8e0a2c0:
Acceptance Criteria of
docs/agent/tasks/task-1674-argocd-pre-delete-finalizers.md:No Acceptance Criteria section.