Skip to content

Commit 78dc23f

Browse files
gkechjvpasinatto
authored andcommitted
K8SPG-719 fixes on the deploy_pmm3_server for openshift (#1224)
* K8SPG-719 fixes on the deploy_pmm3_server for openshift * shfmt * remove platform specific set * move init on top of the function * add retry func
1 parent a5cd0e2 commit 78dc23f

File tree

1 file changed

+32
-19
lines changed

1 file changed

+32
-19
lines changed

e2e-tests/functions

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -370,9 +370,14 @@ deploy_pmm_server() {
370370
}
371371

372372
deploy_pmm3_server() {
373-
helm uninstall -n "${NAMESPACE}" pmm || :
373+
helm uninstall -n "${NAMESPACE}" monitoring || :
374+
helm repo remove percona || :
375+
kubectl delete clusterrole monitoring --ignore-not-found
376+
kubectl delete clusterrolebinding monitoring --ignore-not-found
377+
helm repo add percona https://percona.github.io/percona-helm-charts/
378+
helm repo update
379+
374380
if [[ $OPENSHIFT ]]; then
375-
platform=openshift
376381
oc create sa pmm-server -n "$NAMESPACE"
377382
oc adm policy add-scc-to-user privileged -z pmm-server -n "$NAMESPACE"
378383

@@ -384,24 +389,32 @@ deploy_pmm3_server() {
384389
oc create rolebinding pmm-pg-operator-namespace-only --role percona-postgresql-operator --serviceaccount=$NAMESPACE:pmm-server -n "${NAMESPACE}"
385390
oc patch role/percona-postgresql-operator --type json -p='[{"op":"add","path": "/rules/-","value":{"apiGroups":["security.openshift.io"],"resources":["securitycontextconstraints"],"verbs":["use"],"resourceNames":["privileged"]}}]' -n "$NAMESPACE"
386391
fi
387-
helm install monitoring --set imageTag=${IMAGE_PMM3_SERVER#*:} --set imageRepo=${IMAGE_PMM3_SERVER%:*} --set platform=$platform --set sa=pmm-server --set supresshttp2=false https://percona-charts.storage.googleapis.com/pmm-server-${PMM_SERVER_VERSION}.tgz -n "$NAMESPACE"
388-
else
389-
platform=kubernetes
390-
391-
helm uninstall -n "${NAMESPACE}" monitoring || :
392-
helm repo remove percona || :
393-
kubectl delete clusterrole monitoring --ignore-not-found
394-
kubectl delete clusterrolebinding monitoring --ignore-not-found
395-
396-
helm repo add percona https://percona.github.io/percona-helm-charts/
397-
helm install monitoring percona/pmm -n "${NAMESPACE}" \
398-
--set fullnameOverride=monitoring \
399-
--set image.tag=${IMAGE_PMM3_SERVER#*:} \
400-
--set image.repository=${IMAGE_PMM3_SERVER%:*} \
401-
--set service.type=LoadBalancer \
402-
--set platform="$platform" \
403-
--force
392+
local additional_params="--set platform=openshift --set supresshttp2=false --set serviceAccount.create=false --set serviceAccount.name=pmm-server"
404393
fi
394+
395+
retry 10 60 helm install monitoring percona/pmm -n "${NAMESPACE}" \
396+
--set fullnameOverride=monitoring \
397+
--set image.tag=${IMAGE_PMM3_SERVER#*:} \
398+
--set image.repository=${IMAGE_PMM3_SERVER%:*} \
399+
--set service.type=LoadBalancer \
400+
$additional_params \
401+
--force
402+
}
403+
404+
retry() {
405+
local max=$1
406+
local delay=$2
407+
shift 2 # cut delay and max args
408+
local n=1
409+
410+
until "$@"; do
411+
if [[ $n -ge $max ]]; then
412+
echo "The command '$@' has failed after $n attempts."
413+
exit 1
414+
fi
415+
((n++))
416+
sleep $delay
417+
done
405418
}
406419

407420
generate_pmm_api_key() {

0 commit comments

Comments
 (0)