Skip to content

Commit

Permalink
[patch] fix for zen metastore patch work (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
caroazad authored Nov 13, 2024
1 parent b7d8055 commit 25d94f2
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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 "================================================================================"
Expand Down Expand Up @@ -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

0 comments on commit 25d94f2

Please sign in to comment.