From 6d50e0539cf3036ffbab29ca3b85888405d9e298 Mon Sep 17 00:00:00 2001 From: Carson Dunbar Date: Wed, 13 Dec 2023 21:40:03 +0000 Subject: [PATCH] Update to address PR review --- .../scripts/wait-for-startup-status.sh | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/community/modules/scripts/wait-for-startup/scripts/wait-for-startup-status.sh b/community/modules/scripts/wait-for-startup/scripts/wait-for-startup-status.sh index 4d7c8f5a16..0c9720203c 100755 --- a/community/modules/scripts/wait-for-startup/scripts/wait-for-startup-status.sh +++ b/community/modules/scripts/wait-for-startup/scripts/wait-for-startup-status.sh @@ -36,14 +36,19 @@ c1grep() { grep "$@" || test $? = 1; } now=$(date +%s) deadline=$((now + TIMEOUT)) error_file=$(mktemp) -fetch_cmd="gcloud compute instances get-serial-port-output ${INSTANCE_NAME} --port 1 --zone ${ZONE} --project ${PROJECT_ID}" +fetch_cmd="gcloud compute instances get-serial-port-output ${INSTANCE_NAME} \ + --port 1 --zone ${ZONE} --project ${PROJECT_ID}" +# Match string for all finish types of the old guest agent and successful +# finishes on the new guest agent FINISH_LINE="startup-script exit status" +# Match string for failures on the new guest agent FINISH_LINE_ERR="Script.*failed with error:" until [[ now -gt deadline ]]; do ser_log=$( set -o pipefail - ${fetch_cmd} 2>"${error_file}" | c1grep "${FINISH_LINE}\|${FINISH_LINE_ERR}" + ${fetch_cmd} 2>"${error_file}" | + c1grep "${FINISH_LINE}\|${FINISH_LINE_ERR}" ) || { cat "${error_file}" exit 1 @@ -54,6 +59,8 @@ until [[ now -gt deadline ]]; do now=$(date +%s) done +# This line checks for an exit code - the assumption is that there is a number +# at the end of the line and it is an exit code STATUS=$(sed -r 's/.*([0-9]+)\s*$/\1/' <<<"${ser_log}" | uniq) # This specific text is monitored for in tests, do not change. INSPECT_OUTPUT_TEXT="To inspect the startup script output, please run:"