From 5d3806316f01cb75040e557960dfcdd80282708d Mon Sep 17 00:00:00 2001
From: Gustavo Ornaghi Antunes <gustavo.ornaghiantunes@windriver.com>
Date: Thu, 3 Aug 2023 11:47:23 -0300
Subject: [PATCH] Properly disable platform-integ-apps charts

Pods were not being deleted when rbd-provisioner or cephfs-provisioner
charts are disabled and then reapplied the app.
We needed to add new value in helm.sh/hook annotation on deployment
resource to delete pods when chart is disabled and then reapplied
platform-integ-apps.

Test Plan:
PASS: Apply platform-integ-apps, disable rbd-provisioner chart,
then reapply App and Check if chart related pods, FluxCD helmrelease
and helm release are all removed.
PASS: Apply platform-integ-apps, disable cephfs-provisioner chart,
then reapply App and Check if chart related pods, FluxCD helmrelease
and helm release are all removed.

Closes-Bug: #2029496

Change-Id: Ie4353cab3cf93abf362dc1e55265d4eb6a9d017e
Signed-off-by: Gustavo Ornaghi Antunes <gustavo.ornaghiantunes@windriver.com>
---
 ...-add-annotations-to-provisioner-deployment.patch | 13 +++++++------
 ...-add-annotations-to-provisioner-deployment.patch | 11 ++++++-----
 2 files changed, 13 insertions(+), 11 deletions(-)

diff --git a/platform-helm/debian/deb_folder/patches/0005-ceph-csi-cephfs-add-annotations-to-provisioner-deployment.patch b/platform-helm/debian/deb_folder/patches/0005-ceph-csi-cephfs-add-annotations-to-provisioner-deployment.patch
index 10a9f84..3b1f62a 100644
--- a/platform-helm/debian/deb_folder/patches/0005-ceph-csi-cephfs-add-annotations-to-provisioner-deployment.patch
+++ b/platform-helm/debian/deb_folder/patches/0005-ceph-csi-cephfs-add-annotations-to-provisioner-deployment.patch
@@ -1,16 +1,17 @@
-From 3636dd3743e4d03394576464132d3df005c41848 Mon Sep 17 00:00:00 2001
-From: Erickson Silva de Oliveira <Erickson.SilvadeOliveira@windriver.com>
-Date: Mon, 20 Mar 2023 17:37:28 -0300
+From e0afca6467c6986ca8f6f1facbc6859a3c42ecf5 Mon Sep 17 00:00:00 2001
+From: Gustavo Ornaghi Antunes <gustavo.ornaghiantunes@windriver.com>
+Date: Fri, 04 Aug 2023 10:20:51 -0300
 Subject: [PATCH] ceph-csi-cephfs: add annotations to provisioner-deployment.yaml
 
 Signed-off-by: Hediberto Cavalcante da Silva <hediberto.cavalcantedasilva@windriver.com>
 Signed-off-by: Erickson Silva de Oliveira <Erickson.SilvadeOliveira@windriver.com>
+Signed-off-by: Gustavo Ornaghi Antunes <gustavo.ornaghiantunes@windriver.com>
 ---
  charts/ceph-csi-cephfs/templates/provisioner-deployment.yaml | 5 ++++-
  1 file changed, 4 insertions(+), 1 deletion(-)
 
 diff --git a/charts/ceph-csi-cephfs/templates/provisioner-deployment.yaml b/charts/ceph-csi-cephfs/templates/provisioner-deployment.yaml
-index 13c083aba..462ee6aaa 100644
+index dcc15ee..2d7c815 100644
 --- a/charts/ceph-csi-cephfs/templates/provisioner-deployment.yaml
 +++ b/charts/ceph-csi-cephfs/templates/provisioner-deployment.yaml
 @@ -10,6 +10,9 @@ metadata:
@@ -18,12 +19,12 @@ index 13c083aba..462ee6aaa 100644
      heritage: {{ .Release.Service }}
      {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
 +  annotations:
-+    "helm.sh/hook": "post-upgrade, post-install"
++    "helm.sh/hook": "post-upgrade, post-install, post-delete"
 +    "helm.sh/hook-delete-policy": "before-hook-creation"
  spec:
    replicas: {{ .Values.provisioner.replicaCount }}
    strategy:
-@@ -86,7 +89,7 @@ spec:
+@@ -98,7 +101,7 @@ spec:
              - "--v={{ .Values.sidecarLogLevel }}"
              - "--timeout={{ .Values.provisioner.timeout }}"
              - "--leader-election=true"
diff --git a/platform-helm/debian/deb_folder/patches/0010-ceph-csi-rbd-add-annotations-to-provisioner-deployment.patch b/platform-helm/debian/deb_folder/patches/0010-ceph-csi-rbd-add-annotations-to-provisioner-deployment.patch
index 742f54f..15b12ab 100644
--- a/platform-helm/debian/deb_folder/patches/0010-ceph-csi-rbd-add-annotations-to-provisioner-deployment.patch
+++ b/platform-helm/debian/deb_folder/patches/0010-ceph-csi-rbd-add-annotations-to-provisioner-deployment.patch
@@ -1,16 +1,17 @@
-From a23aa2ccc5e14f8cc2abcd17c2e0e97891f1c2cb Mon Sep 17 00:00:00 2001
-From: Erickson Silva de Oliveira <Erickson.SilvadeOliveira@windriver.com>
-Date: Mon, 20 Mar 2023 17:44:46 -0300
+From fbb1dd8e7d2e35f59d47c5903ce638932fb20f55 Mon Sep 17 00:00:00 2001
+From: Gustavo Ornaghi Antunes <gustavo.ornaghiantunes@windriver.com>
+Date: Fri, 04 Aug 2023 10:20:51 -0300
 Subject: [PATCH] ceph-csi-rbd: add annotations to provisioner-deployment.yaml
 
 Signed-off-by: Hediberto Cavalcante da Silva <hediberto.cavalcantedasilva@windriver.com>
 Signed-off-by: Erickson Silva de Oliveira <Erickson.SilvadeOliveira@windriver.com>
+Signed-off-by: Gustavo Ornaghi Antunes <gustavo.ornaghiantunes@windriver.com>
 ---
  charts/ceph-csi-rbd/templates/provisioner-deployment.yaml | 3 +++
  1 file changed, 3 insertions(+)
 
 diff --git a/charts/ceph-csi-rbd/templates/provisioner-deployment.yaml b/charts/ceph-csi-rbd/templates/provisioner-deployment.yaml
-index fc1f28cdf..b9903f666 100644
+index 824377a..f31b5d6 100644
 --- a/charts/ceph-csi-rbd/templates/provisioner-deployment.yaml
 +++ b/charts/ceph-csi-rbd/templates/provisioner-deployment.yaml
 @@ -10,6 +10,9 @@ metadata:
@@ -18,7 +19,7 @@ index fc1f28cdf..b9903f666 100644
      heritage: {{ .Release.Service }}
      {{- with .Values.commonLabels }}{{ toYaml . | trim | nindent 4 }}{{- end }}
 +  annotations:
-+    "helm.sh/hook": "post-upgrade, post-install"
++    "helm.sh/hook": "post-upgrade, post-install, post-delete"
 +    "helm.sh/hook-delete-policy": "before-hook-creation"
  spec:
    replicas: {{ .Values.provisioner.replicaCount }}