Skip to content

Commit

Permalink
Restart auth service (#2321)
Browse files Browse the repository at this point in the history
* restart platform-auth-service after restore cs-db

Signed-off-by: Allen Li <liyuchen223@gmail.com>

* change format

Signed-off-by: Allen Li <liyuchen223@gmail.com>

* add configmap permission

Signed-off-by: Allen Li <liyuchen223@gmail.com>

* consistently check auth-service

Signed-off-by: Allen Li <liyuchen223@gmail.com>

* reset values in while loop

Signed-off-by: Allen Li <liyuchen223@gmail.com>

---------

Signed-off-by: Allen Li <liyuchen223@gmail.com>
  • Loading branch information
qpdpQ authored Jan 16, 2025
1 parent 8befe43 commit 9d66bcc
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions velero/schedule/common-service-db/cs-db-br-script-cm.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9d66bcc

Please sign in to comment.