Fix infinity loop when all actions are already completed

Wait-for-shipyard sctipt was just checking actions that are
in "Processing" state, but if some actions are "Complete",
it comes to infinity loop.

Change-Id: I9c007a60227159af561f5ceacf5fc3dd469fce0c
This commit is contained in:
Daniel Pawlik 2019-08-01 08:21:24 +00:00 committed by Drew Walters
parent 5d375ff8bd
commit aea332029a
1 changed files with 8 additions and 1 deletions

View File

@ -19,11 +19,18 @@ set -e
REPO_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )"/../../ >/dev/null 2>&1 && pwd )"
: "${SHIPYARD:=${REPO_DIR}/tools/airship shipyard}"
ACTION=$(${SHIPYARD} get actions | grep -i "Processing" | awk '{ print $2 }')
ACTION=$(${SHIPYARD} get actions | tail -n +2 | grep "action\/" | grep -iE "Processing|Complete" | awk '{ print $2 }')
echo -e "\nWaiting for $ACTION..."
while true; do
# Check if there is just one action ongoing or completed.
# If yes, break the loop.
if [ "$(echo "${ACTION}" | wc -l)" -eq 1 ]; then
echo -e "\n$ACTION has been completed"
break
fi
# Print the status of tasks
${SHIPYARD} describe "${ACTION}"