From 2c623e947e1a0a92710fa3f94b9e6e1e2e71f563 Mon Sep 17 00:00:00 2001 From: Denilson Nastacio Date: Thu, 7 Dec 2023 19:44:53 -0500 Subject: [PATCH] fix: Patch Zen database for CP4D Signed-off-by: Denilson Nastacio --- config/cloudpaks/cp4d/Chart.yaml | 2 +- .../0100-sync-install-zen-workaround.yaml | 57 +++++++++++++++++++ 2 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 config/cloudpaks/cp4d/templates/0100-sync-install-zen-workaround.yaml diff --git a/config/cloudpaks/cp4d/Chart.yaml b/config/cloudpaks/cp4d/Chart.yaml index 3452f0de..36c795f3 100644 --- a/config/cloudpaks/cp4d/Chart.yaml +++ b/config/cloudpaks/cp4d/Chart.yaml @@ -16,7 +16,7 @@ type: application # This is the chart version. This version number should be incremented each time you make changes # to the chart and its templates, including the app version. # Versions are expected to follow Semantic Versioning (https://semver.org/) -version: 0.8.0 +version: 0.8.1 # This is the version number of the application being deployed. This version number should be # incremented each time you make changes to the application. Versions are not expected to diff --git a/config/cloudpaks/cp4d/templates/0100-sync-install-zen-workaround.yaml b/config/cloudpaks/cp4d/templates/0100-sync-install-zen-workaround.yaml new file mode 100644 index 00000000..f533d5ec --- /dev/null +++ b/config/cloudpaks/cp4d/templates/0100-sync-install-zen-workaround.yaml @@ -0,0 +1,57 @@ +--- +# https://www.ibm.com/support/pages/node/7087504 +apiVersion: batch/v1 +kind: Job +metadata: + annotations: + argocd.argoproj.io/hook: Sync + argocd.argoproj.io/hook-delete-policy: BeforeHookCreation + argocd.argoproj.io/sync-wave: "101" + name: sync-cp4d-install-zen-workaround + namespace: {{.Values.metadata.argocd_namespace}} +spec: + template: + spec: + containers: + - name: patch-zen-database + image: "icr.io/cpopen/cpd/olm-utils-v2:{{.Values.version}}" + env: + - name: PROJECT_CPD_INST_OPERANDS + value: {{.Values.metadata.operands_namespace}} + command: + - /bin/bash + - -c + - | + set -eo pipefail + set -x + + result=1 + + while [ ${result} -eq 1 ] && [ ${SECONDS} -lt 7200 ]; do + do + oc get deployment zen-databases \ + -n ${PROJECT_CPD_INST_OPERANDS} \ + && result=0 \ + || { + echo "INFO: Waiting on Zen database deployment to patch it" + sleep 60 + } + done + + if [ ${result} -eq 0 ]; then + oc patch deployment zen-databases \ + -n ${PROJECT_CPD_INST_OPERANDS} \ + --type='json' \ + -p='[{"op": "add", "path": "/spec/template/spec/containers/0/env/-", "value": {"name": "npm_config_cache", "value": "/tmp"}}]' \ + || { + echo "ERROR: CP4D installation failed." + result=1 + } + fi + + exit ${result} + + restartPolicy: Never + serviceAccountName: {{.Values.serviceaccount.argocd_application_controller}} + + backoffLimit: 2