Skip to content

Commit

Permalink
[patch] Fix cp4d postgres license issue (#208)
Browse files Browse the repository at this point in the history
  • Loading branch information
whitfiea authored Oct 3, 2024
1 parent 6b47a6f commit 1540d4e
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,16 @@ rules:
- ''
resources:
- serviceaccounts

- verbs:
- get
- list
- patch
- create
- delete
apiGroups:
- 'batch'
resources:
- jobs
---
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-v1-{{ .Values | toYaml | adler32sum }}"
name: "cpd-patch-zenservices-v2-{{ .Values | toYaml | adler32sum }}"
namespace: "{{ .Values.cpd_operators_namespace }}"
annotations:
argocd.argoproj.io/sync-wave: "087"
Expand Down Expand Up @@ -37,11 +37,47 @@ spec:
- name: CPD_SCALE_CONFIG
value: {{ .Values.cpd_scale_config }}
command:
- /bin/sh
- /bin/bash
- -c
- |
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 "================================================================================"
echo "Wait for ZenService Cr and patch it if needed"
Expand Down

0 comments on commit 1540d4e

Please sign in to comment.