From c9adab043ed47cecd7eaec62edde3c7b89d1f360 Mon Sep 17 00:00:00 2001 From: Philip Kotliyakov Date: Thu, 11 Dec 2025 09:17:40 +0200 Subject: [PATCH 01/12] added annotation to app proxy deployment so it wont get deleted during argo deletion --- .../templates/_components/cap-app-proxy/_deployment.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/charts/gitops-runtime/templates/_components/cap-app-proxy/_deployment.yaml b/charts/gitops-runtime/templates/_components/cap-app-proxy/_deployment.yaml index e00a55bb2..74bf68dbc 100644 --- a/charts/gitops-runtime/templates/_components/cap-app-proxy/_deployment.yaml +++ b/charts/gitops-runtime/templates/_components/cap-app-proxy/_deployment.yaml @@ -3,6 +3,8 @@ apiVersion: apps/v1 kind: Deployment metadata: name: {{ include "cap-app-proxy.fullname" . }} + annotations: + argocd.argoproj.io/sync-options: Delete=false labels: {{- include "cap-app-proxy.labels" . | nindent 4 }} spec: From e3564fc4701cb502efd66c9948ef587f28ad86f0 Mon Sep 17 00:00:00 2001 From: Philip Kotliyakov Date: Sun, 14 Dec 2025 12:49:35 +0200 Subject: [PATCH 02/12] added annotation to argo controller --- charts/gitops-runtime/values.yaml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/charts/gitops-runtime/values.yaml b/charts/gitops-runtime/values.yaml index 22ff23e99..0d4712947 100644 --- a/charts/gitops-runtime/values.yaml +++ b/charts/gitops-runtime/values.yaml @@ -290,6 +290,9 @@ argo-cd: params: server.insecure: true application.namespaces: 'cf-*' + controller: + statefulsetAnnotations: + argocd.argoproj.io/sync-options: "Delete=false" #----------------------------------------------------------------------------------------------------------------------- # Argo Events #----------------------------------------------------------------------------------------------------------------------- From 057970277370b3d5f1abb46505d93a60e1d4eabd Mon Sep 17 00:00:00 2001 From: Philip Kotliyakov Date: Sun, 14 Dec 2025 14:12:14 +0200 Subject: [PATCH 03/12] linting --- charts/gitops-runtime/values.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/gitops-runtime/values.yaml b/charts/gitops-runtime/values.yaml index 0d4712947..405b871b5 100644 --- a/charts/gitops-runtime/values.yaml +++ b/charts/gitops-runtime/values.yaml @@ -291,8 +291,8 @@ argo-cd: server.insecure: true application.namespaces: 'cf-*' controller: - statefulsetAnnotations: - argocd.argoproj.io/sync-options: "Delete=false" + statefulsetAnnotations: + argocd.argoproj.io/sync-options: "Delete=false" #----------------------------------------------------------------------------------------------------------------------- # Argo Events #----------------------------------------------------------------------------------------------------------------------- From 2e1de46448247fa93b0c76b151a53ab28f4d9883 Mon Sep 17 00:00:00 2001 From: Philip Kotliyakov Date: Sun, 14 Dec 2025 14:47:59 +0200 Subject: [PATCH 04/12] bump From 0edfbfc977dc3574bf21a82e4e11013078145507 Mon Sep 17 00:00:00 2001 From: Philip Kotliyakov Date: Mon, 15 Dec 2025 12:09:59 +0200 Subject: [PATCH 05/12] added hook to delete applications --- .../templates/hooks/pre-uninstall/cleanup-resources.yaml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml b/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml index ecd385a87..5c4dcf3e4 100644 --- a/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml +++ b/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml @@ -20,10 +20,7 @@ spec: command: ["sh", "-c"] args: - | - kubectl patch EventBus $(kubectl get eventbus -l codefresh.io/internal=true | awk 'NR>1{print $1}' | xargs) -p '{"metadata":{"finalizers":null}}' --type=merge && \ - kubectl patch Eventsource $(kubectl get EventSource -l codefresh.io/internal=true | awk 'NR>1{print $1}' | xargs) -p '{"metadata":{"finalizers":null}}' --type=merge && \ - kubectl patch Sensor $(kubectl get Sensor -l codefresh.io/internal=true | awk 'NR>1{print $1}' | xargs) -p '{"metadata":{"finalizers":null}}' --type=merge ; - return 0 + kubectl get applications -A -l codefresh.io/internal=true -o name | xargs -r -I{} kubectl patch {} -p '{"metadata":{"finalizers":null}}' --type=merge || true {{- with .Values.installer.nodeSelector | default .Values.global.nodeSelector }} nodeSelector: {{ toYaml . | nindent 8 }} {{- end }} From ba366c4849e8673d7dca824e7033df82437f364f Mon Sep 17 00:00:00 2001 From: Philip Kotliyakov Date: Mon, 15 Dec 2025 15:00:14 +0200 Subject: [PATCH 06/12] adj command to handle namespaced installations --- .../templates/hooks/pre-uninstall/cleanup-resources.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml b/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml index 5c4dcf3e4..249aaf094 100644 --- a/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml +++ b/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml @@ -20,7 +20,8 @@ spec: command: ["sh", "-c"] args: - | - kubectl get applications -A -l codefresh.io/internal=true -o name | xargs -r -I{} kubectl patch {} -p '{"metadata":{"finalizers":null}}' --type=merge || true + kubectl get applications -n {{ .Release.Namespace }} -l codefresh.io/internal=true -o jsonpath='{.items[*].metadata.name}' \ + | xargs -r -n1 -I{} kubectl patch application -n {{ .Release.Namespace }} {} -p '{"metadata":{"finalizers":null}}' --type=merge || true {{- with .Values.installer.nodeSelector | default .Values.global.nodeSelector }} nodeSelector: {{ toYaml . | nindent 8 }} {{- end }} From 62605844c5334d280a1c7bced3708e7a65a482ef Mon Sep 17 00:00:00 2001 From: Philip Kotliyakov Date: Mon, 15 Dec 2025 15:23:26 +0200 Subject: [PATCH 07/12] bump From eaf8cf79536e5a3c145b264da35e40076ff6f81b Mon Sep 17 00:00:00 2001 From: Philip Kotliyakov Date: Mon, 15 Dec 2025 16:17:12 +0200 Subject: [PATCH 08/12] bump From 0bd90e7b50d91e4cacbb9fb300a567d35c0eadc7 Mon Sep 17 00:00:00 2001 From: Philip Kotliyakov Date: Tue, 16 Dec 2025 07:44:47 +0200 Subject: [PATCH 09/12] bump From 796909f2aefb16af49e3b286f7b5f93dc9071f1c Mon Sep 17 00:00:00 2001 From: Philip Kotliyakov Date: Tue, 16 Dec 2025 10:09:36 +0200 Subject: [PATCH 10/12] added clean up for codefresh secret and git integration --- .../templates/hooks/pre-uninstall/cleanup-resources.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml b/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml index 249aaf094..c3526f92c 100644 --- a/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml +++ b/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml @@ -20,8 +20,15 @@ spec: command: ["sh", "-c"] args: - | + # Remove finalizers from internal Argo CD Applications in this runtime namespace kubectl get applications -n {{ .Release.Namespace }} -l codefresh.io/internal=true -o jsonpath='{.items[*].metadata.name}' \ | xargs -r -n1 -I{} kubectl patch application -n {{ .Release.Namespace }} {} -p '{"metadata":{"finalizers":null}}' --type=merge || true + + # Delete runtime token secret in this namespace (if present) + kubectl delete secret codefresh-token -n {{ .Release.Namespace }} --ignore-not-found || true + + # Delete default git integration secret in this namespace (if present) + kubectl delete secret -n {{ .Release.Namespace }} -l 'io.codefresh.integration-type=git,io.codefresh.integration-name=default' --ignore-not-found || true {{- with .Values.installer.nodeSelector | default .Values.global.nodeSelector }} nodeSelector: {{ toYaml . | nindent 8 }} {{- end }} From 4083e678434bf07bc043f08f21804f0c4bc9926c Mon Sep 17 00:00:00 2001 From: Philip Kotliyakov Date: Tue, 16 Dec 2025 10:55:12 +0200 Subject: [PATCH 11/12] added loggin --- .../pre-uninstall/cleanup-resources.yaml | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml b/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml index c3526f92c..f9df4d312 100644 --- a/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml +++ b/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml @@ -20,15 +20,22 @@ spec: command: ["sh", "-c"] args: - | - # Remove finalizers from internal Argo CD Applications in this runtime namespace + set -e + + echo "[cleanup] Namespace: {{ .Release.Namespace }}" + + echo "[cleanup] Patching internal Argo CD Applications finalizers..." kubectl get applications -n {{ .Release.Namespace }} -l codefresh.io/internal=true -o jsonpath='{.items[*].metadata.name}' \ - | xargs -r -n1 -I{} kubectl patch application -n {{ .Release.Namespace }} {} -p '{"metadata":{"finalizers":null}}' --type=merge || true + | xargs -r -n1 -I{} sh -c 'echo "[cleanup] Patching application: {}"; kubectl patch application -n {{ .Release.Namespace }} {} -p '\''{"metadata":{"finalizers":null}}'\'' --type=merge' \ + || echo "[cleanup] Failed to patch applications (see errors above)" - # Delete runtime token secret in this namespace (if present) - kubectl delete secret codefresh-token -n {{ .Release.Namespace }} --ignore-not-found || true + echo "[cleanup] Deleting codefresh-token secret..." + kubectl delete secret codefresh-token -n {{ .Release.Namespace }} --ignore-not-found \ + || echo "[cleanup] Failed to delete codefresh-token (see errors above)" - # Delete default git integration secret in this namespace (if present) - kubectl delete secret -n {{ .Release.Namespace }} -l 'io.codefresh.integration-type=git,io.codefresh.integration-name=default' --ignore-not-found || true + echo "[cleanup] Deleting default git integration secrets..." + kubectl delete secret -n {{ .Release.Namespace }} -l 'io.codefresh.integration-type=git,io.codefresh.integration-name=default' --ignore-not-found \ + || echo "[cleanup] Failed to delete default git integration secrets (see errors above)" {{- with .Values.installer.nodeSelector | default .Values.global.nodeSelector }} nodeSelector: {{ toYaml . | nindent 8 }} {{- end }} From 8f920502602bc96d368b8bda0044e039099d1525 Mon Sep 17 00:00:00 2001 From: Philip Kotliyakov Date: Tue, 16 Dec 2025 11:24:57 +0200 Subject: [PATCH 12/12] debugging --- .../templates/hooks/pre-uninstall/cleanup-resources.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml b/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml index f9df4d312..ee1bb7f06 100644 --- a/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml +++ b/charts/gitops-runtime/templates/hooks/pre-uninstall/cleanup-resources.yaml @@ -5,7 +5,7 @@ metadata: annotations: helm.sh/hook: pre-delete helm.sh/hook-weight: "5" - helm.sh/hook-delete-policy: hook-succeeded,before-hook-creation + helm.sh/hook-delete-policy: before-hook-creation spec: backoffLimit: 3 template: