Skip to content

Commit

Permalink
print last attempt output
Browse files Browse the repository at this point in the history
  • Loading branch information
coolbry95 committed Jul 20, 2021
1 parent 38d2e93 commit 2c56854
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions tools/ansible/roles/dockerfile/files/wait-for-migrations
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ readonly CMDNAME=$(basename "$0")

readonly MIN_SLEEP=0.5
readonly MAX_SLEEP=30
readonly ATTEMPTS=30
readonly MAX_ATTEMPTS=30
readonly TIMEOUT=60

log_message() { echo "[${CMDNAME}]" "$@" >&2; }
Expand All @@ -26,9 +26,15 @@ wait_for() {
while true; do
log_message "Attempt ${attempt} of ${ATTEMPTS}"

timeout "${TIMEOUT}" \
/bin/bash -c "awx-manage showmigrations | grep '\[ \]'" &>/dev/null \
&& return || rc=$?
if ((MAX_ATTEMPTS != attempt)); then
timeout "${TIMEOUT}" \
/bin/bash -c "awx-manage showmigrations | grep '\[ \]'" &>/dev/null \
&& return || rc=$?
else
timeout "${TIMEOUT}" \
/bin/bash -c "awx-manage showmigrations"
return
fi

(( ++attempt > ATTEMPTS )) && break

Expand Down

0 comments on commit 2c56854

Please sign in to comment.