Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[patch] fix for zen metastore patch work #221

Merged
merged 3 commits into from
Nov 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading