Skip to content

Commit fe18cff

Browse files
author
Dougal Ballantyne
committed
Sanity check only on calls that mutate stack; output CREATE_FAILED errors with status call
1 parent 9a6b01b commit fe18cff

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

cli/cfncluster/cfncluster.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,8 @@ def status(args):
260260
sys.stdout.write('\rStatus: %s' % status)
261261
sys.stdout.flush()
262262
if not args.nowait:
263-
while ((status != 'CREATE_COMPLETE') and (status != 'UPDATE_COMPLETE') and (status != 'ROLLBACK_COMPLETE')):
263+
while ((status != 'CREATE_COMPLETE') and (status != 'UPDATE_COMPLETE')
264+
and (status != 'ROLLBACK_COMPLETE') and (status != 'CREATE_FAILED')):
264265
time.sleep(5)
265266
status = cfnconn.describe_stacks(stack)[0].stack_status
266267
events = cfnconn.describe_stack_events(stack)[0]
@@ -273,6 +274,11 @@ def status(args):
273274
outputs = cfnconn.describe_stacks(stack)[0].outputs
274275
for output in outputs:
275276
print output
277+
elif ((status == 'ROLLBACK_COMPLETE') or (status == 'CREATE_FAILED')):
278+
events = cfnconn.describe_stack_events(stack)
279+
for event in events:
280+
if event.resource_status == 'CREATE_FAILED':
281+
print event.timestamp, event.resource_status, event.resource_type, event.logical_resource_id, event.resource_status_reason
276282
else:
277283
sys.stdout.write('\n')
278284
sys.stdout.flush()
@@ -290,7 +296,7 @@ def status(args):
290296

291297

292298
def delete(args):
293-
print('Terminating: %s' % args.cluster_name)
299+
print('Deleting: %s' % args.cluster_name)
294300
stack = ('cfncluster-' + args.cluster_name)
295301

296302
config = cfnconfig.CfnClusterConfig(args)

cli/cfncluster/cfnconfig.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,12 @@ def __init__(self, args):
7979
self.__sanity_check = __config.getboolean('global', 'sanity_check')
8080
except ConfigParser.NoOptionError:
8181
self.__sanity_check = False
82+
# Only check config on calls that mutate it
83+
__args_func = self.args.func.func_name
84+
if (__args_func == 'create' or __args_func == 'update') and self.__sanity_check is True:
85+
pass
86+
else:
87+
self.__sanity_check = False
8288

8389
# Determine the EC2 region to used used or default to us-east-1
8490
# Order is 1) CLI arg 2) AWS_DEFAULT_REGION env 3) Config file 4) us-east-1

0 commit comments

Comments
 (0)