Skip to content

Commit

Permalink
Add "wait_for_routes" helper script for CronJobs. (#3565)
Browse files Browse the repository at this point in the history
* 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
bpblanken authored Aug 18, 2023
1 parent 81f4ec0 commit 04676d8
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
1 change: 1 addition & 0 deletions deploy/docker/seqr/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ EXPOSE 8000
ENV TERM=xterm

COPY deploy/docker/seqr/readiness_probe /
COPY deploy/docker/seqr/wait_for_routes /
COPY deploy/docker/seqr/bin/*.sh /usr/local/bin/
COPY deploy/docker/seqr/config/*.py ./
COPY deploy/docker/seqr/bashrc /root/.bashrc
Expand Down
26 changes: 26 additions & 0 deletions deploy/docker/seqr/wait_for_routes
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

0 comments on commit 04676d8

Please sign in to comment.