diff --git a/velero/schedule/common-service-db/cs-db-br-script-cm.yaml b/velero/schedule/common-service-db/cs-db-br-script-cm.yaml index 1aea8eb39..3b023affa 100644 --- a/velero/schedule/common-service-db/cs-db-br-script-cm.yaml +++ b/velero/schedule/common-service-db/cs-db-br-script-cm.yaml @@ -144,6 +144,12 @@ data: oc apply -f /tmp/oidc-client-registration.yaml rm -f /tmp/oidc-client-registration.yaml wait_for_oidc + + info "Restarting platform-auth-service..." + oc -n $CSDB_NAMESPACE delete pod -l app.kubernetes.io/instance=platform-auth-service + info "Wait for previous pod to delete..." + sleep 30 + wait_for_auth_service } function wait_for_oidc { @@ -171,6 +177,33 @@ data: fi } + function wait_for_auth_service { + info "Waiting for pod platform-auth-service to restart in namespace $CSDB_NAMESPACE." + deployment_exists=$(oc get deployment platform-auth-service -n $CSDB_NAMESPACE --no-headers || echo "fail") + if [[ $deployment_exists != "fail" ]]; then + replicas=$(oc get deployment platform-auth-service -n $CSDB_NAMESPACE --no-headers -o jsonpath='{.spec.replicas}') + ready_replicas=$(oc get deployment platform-auth-service -n $CSDB_NAMESPACE --no-headers -o jsonpath='{.status.readyReplicas}') + retry_count=60 + while [[ "$replicas" != "$ready_replicas" ]] && [[ $retry_count > 0 ]] + do + info "Wait for pod platform-auth-service to complete. Try again in 5s." + sleep 5 + completed=$(oc get job $job_name -n $CSDB_NAMESPACE --no-headers | awk '{print $2}') + retry_count=$((retry_count-1)) + replicas=$(oc get deployment platform-auth-service -n $CSDB_NAMESPACE --no-headers -o jsonpath='{.spec.replicas}') + ready_replicas=$(oc get deployment platform-auth-service -n $CSDB_NAMESPACE --no-headers -o jsonpath='{.status.readyReplicas}') + done + + if [[ $retry_count == 0 ]] && [[ "$replicas" != "$ready_replicas" ]]; then + error "Timed out waiting for pod platform-auth-service." + else + info "Pod platform-auth-service restarted." + fi + else + error "Deployment platform-auth-service not exist." + fi + } + function wait_for_cluster_cr { info "Waiting for EDB Cluster CR $CLUSTER_CR to complete in namespace $CSDB_NAMESPACE." cluster_cr_exists=$(oc get clusters.postgresql.k8s.enterprisedb.io $CLUSTER_CR -n $CSDB_NAMESPACE --no-headers || echo fail)