diff --git a/instance-applications/110-ibm-cp4d-operators/templates/02-ibm-cp4d_rbac.yaml b/instance-applications/110-ibm-cp4d-operators/templates/02-ibm-cp4d_rbac.yaml index 61622175b..71a88054e 100644 --- a/instance-applications/110-ibm-cp4d-operators/templates/02-ibm-cp4d_rbac.yaml +++ b/instance-applications/110-ibm-cp4d-operators/templates/02-ibm-cp4d_rbac.yaml @@ -250,8 +250,10 @@ rules: - list apiGroups: - packages.operators.coreos.com + - postgresql.k8s.enterprisedb.io resources: - packagemanifests + - clusters --- kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 diff --git a/instance-applications/110-ibm-cp4d/templates/07-ibm-cp4d_patch_zenservice.yaml b/instance-applications/110-ibm-cp4d/templates/07-ibm-cp4d_patch_zenservice.yaml index 03cca9130..d3ee521b7 100644 --- a/instance-applications/110-ibm-cp4d/templates/07-ibm-cp4d_patch_zenservice.yaml +++ b/instance-applications/110-ibm-cp4d/templates/07-ibm-cp4d_patch_zenservice.yaml @@ -2,7 +2,7 @@ apiVersion: batch/v1 kind: Job metadata: - name: cpd-patch-zenservices-v3-{{ omit .Values "junitreporter" | toYaml | adler32sum }} + name: cpd-patch-zenservices-v4-{{ omit .Values "junitreporter" | toYaml | adler32sum }} namespace: "{{ .Values.cpd_operators_namespace }}" annotations: argocd.argoproj.io/sync-wave: "088" @@ -44,41 +44,6 @@ spec: - | set -e - trap 'echo "[ERROR] Error occurred at line $LINENO, exited with $?"; exit 1' ERR - - echo - echo "================================================================================" - echo "Patch zenmetastore postgres job to workaround https://www.ibm.com/support/pages/node/7158524" - echo "================================================================================" - echo - echo "Wait for create-postgres-license-config job to be present" - - wait_period=0 - while true; do - wait_period=$(($wait_period+60)) - if [ $wait_period -gt 1200 ]; then - echo "create-postgres-license-config job is not found after 20 minutes of waiting. exiting..." - exit 1 - else - sleep 60 - fi - - POSTGRES_JOB_LOOKUP=$(oc get job create-postgres-license-config -n ${CPD_OPERATORS_NAMESPACE} --ignore-not-found -ojsonpath='{.spec}') - if [[ ! -z $POSTGRES_JOB_LOOKUP ]]; then - echo "create-postgres-license-config job has been fetched $POSTGRES_JOB_LOOKUP" - IS_PATCHED=$(echo \'$POSTGRES_JOB_LOOKUP\' | grep "cp.icr.io/cp/cpd/edb-postgres-license-provider@sha256:c1670e7dd93c1e65a6659ece644e44aa5c2150809ac1089e2fd6be37dceae4ce" || true) - echo "IS_PATCHED=$IS_PATCHED" - if [[ -z $IS_PATCHED ]]; then - echo "patching create-postgres-license-config..." - oc get job create-postgres-license-config -n ${CPD_OPERATORS_NAMESPACE} -o yaml | \ - sed -e 's/operator.ibm.com\/opreq-control: "true"/operator.ibm.com\/opreq-control: "false"/' \ - -e 's|\(image: \).*|\1"cp.icr.io/cp/cpd/edb-postgres-license-provider@sha256:c1670e7dd93c1e65a6659ece644e44aa5c2150809ac1089e2fd6be37dceae4ce"|' \ - -e '/controller-uid:/d' | \ - oc replace --force -f - - fi - break - fi - done echo echo "================================================================================" @@ -127,6 +92,55 @@ spec: fi done + + echo + echo "================================================================================" + echo "Patch zenmetastore postgres job to workaround https://www.ibm.com/support/pages/node/7158524" + echo "================================================================================" + echo + echo "Wait for Zen Metastore EDB Cluster to be created" + wait_period=0 + while true; do + wait_period=$(($wait_period+60)) + if [ $wait_period -gt 1800 ]; then + echo "Zen Metastore EDB Cluster is not ready after 30 minutes of waiting. exiting..." + exit 1 + else + sleep 60 + fi + + ZENCLUSTER_LOOKUP=$(oc get Cluster zen-metastore-edb -n ${CPD_INSTANCE_NAMESPACE} --ignore-not-found -ojsonpath='{.status}') + if [[ ! -z $ZENCLUSTER_LOOKUP ]]; then + LICENSE_EXP=$(oc get Cluster zen-metastore-edb -n ${CPD_INSTANCE_NAMESPACE} --ignore-not-found -ojsonpath='{.status.licenseStatus.licenseExpiration}') + LICENSE_STATUS=$(oc get Cluster zen-metastore-edb -n ${CPD_INSTANCE_NAMESPACE} --ignore-not-found -ojsonpath='{.status.licenseStatus.licenseStatus}') + + echo + echo "================================================================================" + echo "Debug Zen Metastore Cluster License" + echo "================================================================================" + echo "- License Expiration ................ ${LICENSE_EXP}" + echo "- License Status .................... ${LICENSE_STATUS}" + echo + + if [[ -z $LICENSE_EXP ]]; then + while true; do + POSTGRES_STATUS_LOOKUP=$(oc get job create-postgres-license-config -n ${CPD_OPERATORS_NAMESPACE} --ignore-not-found -ojsonpath='{.status.conditions[].status}') + if [[ $POSTGRES_STATUS_LOOKUP == *"True"* ]]; then + echo "patching create-postgres-license-config job..." + oc get job create-postgres-license-config -n ${CPD_OPERATORS_NAMESPACE} -o yaml | \ + sed -e 's/operator.ibm.com\/opreq-control: "true"/operator.ibm.com\/opreq-control: "false"/' \ + -e 's|\(image: \).*|\1"cp.icr.io/cp/cpd/edb-postgres-license-provider@sha256:c1670e7dd93c1e65a6659ece644e44aa5c2150809ac1089e2fd6be37dceae4ce"|' \ + -e '/controller-uid:/d' | \ + oc replace --force -f - + break + fi + done + fi + break + fi + done + + restartPolicy: Never serviceAccountName: cpd-sa backoffLimit: 4