-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add "wait_for_routes" helper script for CronJobs. (#3565)
* add wait_for_routes script * add wait * wait for routes * Add wait_for_routes helper script * Flush out description * Update wait_for_routes
- Loading branch information
Showing
2 changed files
with
27 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/bash | ||
|
||
### | ||
# Waits for network endpoints. Intended usage is within Kubernetes CronJobs to wait for sidecar availability. | ||
# Usage: ./wait_for_routes https://www.google.com/ https://www.broadinstitute.org https://www.broadins.org | ||
### | ||
|
||
RETRY_COUNT=10 | ||
SLEEP_S=2 | ||
|
||
for route in "$@" | ||
do | ||
retries=0 | ||
until [ "$retries" -ge 10 ] | ||
do | ||
curl -s $route -o /dev/null && echo "Successful ping of $route" && break | ||
retries=$((retries+1)) | ||
if [ "$retries" -eq 10 ]; then | ||
echo "Route ${route} wasn't available after ${RETRY_COUNT} connection attempts" | ||
exit 1 | ||
else | ||
echo "Unable to connect to ${route}, retrying. Attempt ${retries}/${RETRY_COUNT}" | ||
sleep $SLEEP_S | ||
fi | ||
done | ||
done |