Skip to content

Commit c13170f

Browse files
committed
Merge pull request #3487 from econnell/provisioner-error-checking
bug(contrib): check for cloudfront errors on stack creation
2 parents ce21c3b + 7c601ca commit c13170f

1 file changed

Lines changed: 13 additions & 5 deletions

File tree

contrib/ec2/provision-ec2-cluster.sh

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,18 @@ ATTEMPTS=45
4949
SLEEPTIME=10
5050
COUNTER=1
5151
INSTANCE_IDS=""
52-
until [ `wc -w <<< $INSTANCE_IDS` -eq $DEIS_NUM_INSTANCES ]; do
53-
if [ $COUNTER -gt $ATTEMPTS ]; then exit 1; fi # timeout after 7 1/2 minutes
54-
if [ $COUNTER -ne 1 ]; then sleep $SLEEPTIME; fi
55-
echo "Waiting for instances to be created..."
52+
until [ `wc -w <<< $INSTANCE_IDS` -eq $DEIS_NUM_INSTANCES -a "$STACK_STATUS" = "CREATE_COMPLETE" ]; do
53+
if [ $COUNTER -gt $ATTEMPTS ]; then echo "Timed out waiting for instances..." ; exit 1; fi # timeout after 7 1/2 minutes
54+
echo "Waiting for instances to be created... $STACK_STATUS"
55+
sleep $SLEEPTIME
56+
STACK_STATUS=$(aws --output text cloudformation describe-stacks --stack-name $STACK_NAME --query 'Stacks[].StackStatus')
57+
if [ $STACK_STATUS != "CREATE_IN_PROGRESS" -a $STACK_STATUS != "CREATE_COMPLETE" ] ; then
58+
echo "error creating stack: "
59+
aws --output text cloudformation describe-stack-events \
60+
--stack-name $STACK_NAME \
61+
--query 'StackEvents[?ResourceStatus==`CREATE_FAILED`].[LogicalResourceId,ResourceStatusReason]'
62+
exit 1
63+
fi
5664
INSTANCE_IDS=$(aws ec2 describe-instances \
5765
--filters Name=tag:aws:cloudformation:stack-name,Values=$STACK_NAME Name=instance-state-name,Values=running \
5866
--query 'Reservations[].Instances[].[ InstanceId ]' \
@@ -64,7 +72,7 @@ done
6472
COUNTER=1
6573
INSTANCE_STATUSES=""
6674
until [ `wc -w <<< $INSTANCE_STATUSES` -eq $DEIS_NUM_INSTANCES ]; do
67-
if [ $COUNTER -gt $ATTEMPTS ]; then exit 1; fi # timeout after 7 1/2 minutes
75+
if [ $COUNTER -gt $ATTEMPTS ]; then echo "Timed out waiting for instances..." ; exit 1; fi # timeout after 7 1/2 minutes
6876
if [ $COUNTER -ne 1 ]; then sleep $SLEEPTIME; fi
6977
echo "Waiting for instances to pass initial health checks..."
7078
INSTANCE_STATUSES=$(aws ec2 describe-instance-status \

0 commit comments

Comments
 (0)