From b80ce4dc99dfa37842b0c23d62a9ab15fb215478 Mon Sep 17 00:00:00 2001 From: Jackson Loper Date: Thu, 10 Sep 2026 13:51:06 -0400 Subject: [PATCH] Orphan resources when an app leaves the ApplicationSet Removing an app's config.json takes its Application out of the set, and ArgoCD then runs resources-finalizer and deletes everything the app owned. For fider-db that chain reaches real data: Application fider-db -> owns postgresql.cnpg.io/Cluster/fider-db Cluster fider-db -> ownerReference on PVC fider-db-1 (controller: true) PVC fider-db-1 -> PV pvc-df9a66c8, reclaim policy Delete Those three links are observed on the live cluster. The cascade is inferred from documented behaviour -- resources-finalizer deletes an Application's managed resources, and Kubernetes garbage collects an object once its controller owner is gone -- rather than from having watched it happen. The Retain policy applied after the August CNPG incident covers pvc-00a3f621, which is Released; the bound volume since the 08-29 rebuild is Delete. This is a different path from `prune`. The note there is correct that prune cannot reach a PVC, since no PVC in this cluster is managed by ArgoCD -- but the finalizer does not prune, it deletes the Cluster, and Kubernetes garbage collects the PVC from the ownerReference. With this set, removing a config.json leaves the resources running and cleanup becomes a deliberate separate act. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_01MeFy2jujRA8ScQqRAshc1f --- applications/applicationset.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/applications/applicationset.yaml b/applications/applicationset.yaml index 611611d..908adf6 100644 --- a/applications/applicationset.yaml +++ b/applications/applicationset.yaml @@ -9,6 +9,25 @@ spec: revision: "HEAD" files: - path: "applications/**/config.json" + + syncPolicy: + # Removing an app's config.json takes its Application out of this set, and by + # default ArgoCD then runs resources-finalizer and deletes everything the app + # owned. That is a different path from `prune` below, and it does reach data: + # + # Application fider-db -> owns postgresql.cnpg.io/Cluster/fider-db + # Cluster fider-db -> ownerReference on PVC fider-db-1 (controller) + # PVC fider-db-1 -> PV pvc-df9a66c8, reclaim policy Delete + # + # So retiring or migrating an app destroys its database. `prune` genuinely + # cannot reach a PVC, because no PVC here is managed by ArgoCD -- but the + # finalizer does not prune, it deletes the Cluster, and Kubernetes garbage + # collects the PVC from the ownerReference. + # + # With this set, removing a config.json orphans the resources instead. They + # keep running, and cleanup becomes a deliberate separate act. + preserveResourcesOnDeletion: true + template: metadata: name: "{{application.name}}"