99from boto .ec2 .ec2object import TaggedEC2Object
1010from boto .ec2 .instance import Instance
1111from boto .ec2 .spotinstancerequest import SpotInstanceRequest
12- from boto .exception import EC2ResponseError
12+ from boto .exception import EC2ResponseError , BotoServerError
1313
1414from cgcloud .lib .util import UserError
1515
@@ -26,7 +26,7 @@ def not_found( e ):
2626
2727def retry_ec2 ( retry_after = a_short_time , retry_for = 10 * a_short_time , retry_while = not_found ):
2828 t = retry_after
29- return retry ( delays = (t ,t , t * 2 , t * 4 ), timeout = retry_for , predicate = retry_while )
29+ return retry ( delays = (t , t , t * 2 , t * 4 ), timeout = retry_for , predicate = retry_while )
3030
3131
3232class EC2VolumeHelper ( object ):
@@ -343,11 +343,12 @@ def spot_request_not_found( e ):
343343
344344
345345def create_spot_instances ( ec2 , price , image_id , spec ,
346- num_instances = 1 , timeout = None , tentative = False , tags = None ):
346+ num_instances = 1 , timeout = None , tentative = False , tags = None ):
347347 """
348348 :rtype: Iterator[list[Instance]]
349349 """
350- def spotRequestNotFound (e ):
350+
351+ def spotRequestNotFound ( e ):
351352 return e .error_code == "InvalidSpotInstanceRequestID.NotFound"
352353
353354 for attempt in retry_ec2 ( retry_for = a_long_time ,
@@ -357,9 +358,9 @@ def spotRequestNotFound(e):
357358
358359 if tags is not None :
359360 for requestID in (request .id for request in requests ):
360- for attempt in retry_ec2 (retry_while = spotRequestNotFound ):
361+ for attempt in retry_ec2 ( retry_while = spotRequestNotFound ):
361362 with attempt :
362- ec2 .create_tags ([ requestID ], tags )
363+ ec2 .create_tags ( [ requestID ], tags )
363364
364365 num_active , num_other = 0 , 0
365366 # noinspection PyUnboundLocalVariable,PyTypeChecker
@@ -391,6 +392,7 @@ def spotRequestNotFound(e):
391392
392393
393394def inconsistencies_detected ( e ):
395+ if not isinstance ( e , BotoServerError ): return False
394396 if e .code == 'InvalidGroup.NotFound' : return True
395397 m = e .error_message .lower ( )
396398 return 'invalid iam instance profile' in m or 'no associated iam roles' in m
0 commit comments