forked from kubeflow/manifests
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add tests/gh-actions/wait_for_kubeflow_m2m_oidc_configurator.sh
Signed-off-by: Krzysztof Romanowski <[email protected]>
- Loading branch information
1 parent
9fcf494
commit 5c2157b
Showing
3 changed files
with
51 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
tests/gh-actions/wait_for_kubeflow_m2m_oidc_configurator.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
#!/bin/bash | ||
|
||
CRONJOB_NAME=kubeflow-m2m-oidc-configurator | ||
NAMESPACE=istio-system | ||
|
||
# Function to get the latest Job created by the CronJob | ||
get_latest_job() { | ||
kubectl get jobs -n "${NAMESPACE}" \ | ||
--sort-by=.metadata.creationTimestamp -o json \ | ||
| jq --arg cronjob_name "${CRONJOB_NAME}" -r '.items[] | select(.metadata.ownerReferences[] | select(.name==$cronjob_name)) | .metadata.name' \ | ||
| tail -n 1 | ||
} | ||
|
||
# Wait until a Job is created | ||
echo "Waiting for a Job to be created by the ${CRONJOB_NAME} CronJob..." | ||
while true; do | ||
JOB_NAME=$(get_latest_job) | ||
if [[ -n "${JOB_NAME}" ]]; then | ||
echo "Job ${JOB_NAME} created." | ||
break | ||
fi | ||
sleep 5 | ||
echo "Waiting..." | ||
done | ||
|
||
# Wait for the Job to complete successfully | ||
echo "Waiting for the Job ${JOB_NAME} to complete..." | ||
while true; do | ||
STATUS=$(kubectl get job "${JOB_NAME}" -n "${NAMESPACE}" -o jsonpath='{.status.conditions[?(@.type=="Complete")].status}') | ||
if [[ "${STATUS}" == "True" ]]; then | ||
echo "Job ${JOB_NAME} completed successfully." | ||
break | ||
fi | ||
|
||
FAILED=$(kubectl get job "${JOB_NAME}" -n "${NAMESPACE}" -o jsonpath='{.status.conditions[?(@.type=="Failed")].status}') | ||
if [[ "${FAILED}" == "True" ]]; then | ||
echo "Job ${JOB_NAME} failed." | ||
exit 1 | ||
fi | ||
sleep 5 | ||
done |