From 2682c9ae2c936d08296869f75f460bb50918bb6c Mon Sep 17 00:00:00 2001 From: Sergii Golovatiuk Date: Thu, 6 Dec 2018 11:59:24 +0100 Subject: [PATCH] Don't wait on ERROR VM state Detect ERROR state and exit immediately rather than waiting timeout. Change-Id: Ib20d03b73123e1390fffcd14fd373c93342bb9d8 (cherry picked from commit d1888ac7cfd1a345a704c657ce52476da3b7e17b) --- templates/workload_launch.sh.j2 | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/templates/workload_launch.sh.j2 b/templates/workload_launch.sh.j2 index 1347d11c..287a2098 100644 --- a/templates/workload_launch.sh.j2 +++ b/templates/workload_launch.sh.j2 @@ -180,15 +180,20 @@ openstack server create \ timeout_seconds=120 elapsed_seconds=0 while true; do - INSTANCE_ACTIVE=$(openstack server show ${INSTANCE_NAME} -f json | jq -r '.status') - if [ "${INSTANCE_ACTIVE}" == "ACTIVE" ]; then - echo "${INSTANCE_NAME} reached 'ACTIVE' status" - break - fi + INSTANCE_STATUS=$(openstack server show ${INSTANCE_NAME} -f json | jq -r '.status') + case "${INSTANCE_STATUS}" in + "ACTIVE") + echo "${INSTANCE_NAME} reached 'ACTIVE' status" + break + ;; + "ERROR") + echo "${INSTANCE_NAME} failed" + exit 1 + esac sleep 3 elapsed_seconds=$(expr $elapsed_seconds + 3) if [ $elapsed_seconds -ge $timeout_seconds ]; then - echo "FAILURE: Instance failed to boot." + echo "FAILURE: Instance failed to boot within ${elapsed_seconds} seconds" openstack server show ${INSTANCE_NAME} -f json 2>&1 exit 1 fi