@@ -152,7 +152,8 @@ def stackCreationComplete(stack_name, region, proxy_config):
152
152
log .info ('Checking for status of the stack %s' % stack_name )
153
153
cfn_client = boto3 .client ('cloudformation' , region_name = region , config = proxy_config )
154
154
stacks = cfn_client .describe_stacks (StackName = stack_name )
155
- return stacks ['Stacks' ][0 ]['StackStatus' ] == 'CREATE_COMPLETE'
155
+ return stacks ['Stacks' ][0 ]['StackStatus' ] == 'CREATE_COMPLETE' or \
156
+ stacks ['Stacks' ][0 ]['StackStatus' ] == 'UPDATE_COMPLETE'
156
157
157
158
158
159
def main ():
@@ -183,7 +184,13 @@ def main():
183
184
data = {_CURRENT_IDLETIME : 0 }
184
185
185
186
stack_creation_complete = False
187
+ termination_in_progress = False
186
188
while True :
189
+ # if this node is terminating sleep for a long time and wait for termination
190
+ if termination_in_progress :
191
+ time .sleep (300 )
192
+ log .info ('%s is still terminating' % hostname )
193
+ continue
187
194
time .sleep (60 )
188
195
if not stack_creation_complete :
189
196
stack_creation_complete = stackCreationComplete (stack_name , region , proxy_config )
@@ -217,6 +224,7 @@ def main():
217
224
os .remove (_IDLETIME_FILE )
218
225
try :
219
226
selfTerminate (asg_name , asg_conn , instance_id )
227
+ termination_in_progress = True
220
228
except ClientError as ex :
221
229
log .error ('Failed to terminate instance: %s with exception %s' % (instance_id , ex ))
222
230
lockHost (s , hostname , unlock = True )
0 commit comments