From a3291d4844b21ac35881c8b9a2c6fa8727f95401 Mon Sep 17 00:00:00 2001 From: Denilson Nastacio Date: Fri, 8 Dec 2023 11:54:52 -0500 Subject: [PATCH] fix: Fix sync condition to cleanup IBM Cert Mgr Signed-off-by: Denilson Nastacio --- .../0050-sync-cluster-scoped-operators.yaml | 14 +++++++++++--- .../templates/0100-config-placeholder.yaml | 15 +++++++++++++++ config/cloudpaks/cp4a/operators/values.yaml | 1 + tests/prebuild/yamllint-config.yaml | 1 - 4 files changed, 27 insertions(+), 4 deletions(-) create mode 100644 config/cloudpaks/cp4a/operators/templates/0100-config-placeholder.yaml diff --git a/config/cloudpaks/cp4a/operators/templates/0050-sync-cluster-scoped-operators.yaml b/config/cloudpaks/cp4a/operators/templates/0050-sync-cluster-scoped-operators.yaml index 8773ea0b..951db034 100644 --- a/config/cloudpaks/cp4a/operators/templates/0050-sync-cluster-scoped-operators.yaml +++ b/config/cloudpaks/cp4a/operators/templates/0050-sync-cluster-scoped-operators.yaml @@ -1,5 +1,3 @@ -{{- $red_hat_cert_manager := .Values.red_hat_cert_manager | toString }} -{{- if eq ( default "false" $red_hat_cert_manager ) "false" }} --- apiVersion: batch/v1 kind: Job @@ -19,6 +17,8 @@ spec: env: - name: ARGOCD_NAMESPACE value: "openshift-gitops" + - name: RED_HAT_CERT_MANAGER_ENABLED + value: {{.Values.red_hat_cert_manager}} - name: IBM_CERT_MANAGER_NAMESPACE value: {{.Values.metadata.cert_manager_namespace}} - name: IBM_CERT_MANAGER_CHANNEL @@ -31,6 +31,15 @@ spec: set -x result=0 + if [ "${RED_HAT_CERT_MANAGER_ENABLED}" == "true" ]; then + oc delete Subscription.operators.coreos.com ibm-cert-manager-operator \ + -n "${IBM_CERT_MANAGER_CHANNEL:?}" \ + --ignore-not-found=true \ + oc delete Namespace "${IBM_CERT_MANAGER_CHANNEL:?}" \ + --ignore-not-found=true \ + exit "${result}" + fi + ibm_cert_manager_count=$(oc get Subscription.operators.coreos.com \ -l operators.coreos.com/ibm-cert-manager-operator.ibm-cert-manager \ -A \ @@ -88,4 +97,3 @@ spec: restartPolicy: Never serviceAccountName: {{.Values.serviceaccount.argocd_application_controller}} backoffLimit: 2 -{{- end}} diff --git a/config/cloudpaks/cp4a/operators/templates/0100-config-placeholder.yaml b/config/cloudpaks/cp4a/operators/templates/0100-config-placeholder.yaml new file mode 100644 index 00000000..cc8a7b53 --- /dev/null +++ b/config/cloudpaks/cp4a/operators/templates/0100-config-placeholder.yaml @@ -0,0 +1,15 @@ +# This is not actually used by CP4BA. +# +# ArgoCD cannot recognize changes to the content +# of sync hooks (such as an env variable for a container) +# so this config map contains the env variables +# referenced in sync hooks to ensure ArgoCD realizes +# a relevant config value has changed. +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: gitops-cp4a-dummy + namespace: {{.Values.metadata.argocd_app_namespace}} +data: + red_hat_cert_manager: "{{.Values.red_hat_cert_manager}}" diff --git a/config/cloudpaks/cp4a/operators/values.yaml b/config/cloudpaks/cp4a/operators/values.yaml index 8ed83299..c01fb674 100644 --- a/config/cloudpaks/cp4a/operators/values.yaml +++ b/config/cloudpaks/cp4a/operators/values.yaml @@ -3,6 +3,7 @@ metadata: argocd_app_namespace: ibm-cloudpaks cert_manager_namespace: ibm-cert-manager cert_manager_channel: v4.2 +red_hat_cert_manager: false serviceaccount: argocd_application_controller: openshift-gitops-argocd-application-controller storageclass: diff --git a/tests/prebuild/yamllint-config.yaml b/tests/prebuild/yamllint-config.yaml index be89d212..ad631fb5 100644 --- a/tests/prebuild/yamllint-config.yaml +++ b/tests/prebuild/yamllint-config.yaml @@ -10,7 +10,6 @@ ignore: | config/cloudpaks/cp-shared/operators/templates/0100-rh-cert-manager-operator-group.yaml config/cloudpaks/cp-shared/operators/templates/0110-rh-cert-manager-subscription.yaml config/cloudpaks/cp4a/operators/templates/0000-cp4ba-namespace.yaml - config/cloudpaks/cp4a/operators/templates/0050-sync-cluster-scoped-operators.yaml config/cloudpaks/cp4a/operators/templates/0100-operator-group.yaml config/cloudpaks/cp4i/install-prereqs/templates/0000-namespace.yaml config/cloudpaks/cp4i/install-prereqs/templates/0100-operator-group.yaml