File tree 1 file changed +18
-4
lines changed
1 file changed +18
-4
lines changed Original file line number Diff line number Diff line change 3
3
import json
4
4
import re
5
5
import sys
6
+ import time
6
7
7
8
import common
8
9
86
87
for instance in response_fleet ['Instances' ]:
87
88
88
89
# Retrieve additional instance details
89
- try :
90
- response_describe = client .describe_instances (InstanceIds = instance ['InstanceIds' ])
91
- except Exception as e :
92
- logger .error ('Failed to describe instances %s: %s' % (', ' .join (instance ['InstanceIds' ]), e ))
90
+ nb_retry = 1
91
+ max_retries = 3
92
+ e_msg = None
93
+ while True :
94
+ try :
95
+ response_describe = client .describe_instances (InstanceIds = instance ['InstanceIds' ])
96
+ break
97
+ except Exception as e :
98
+ # Retry if an error is returned because of eventual consistency
99
+ if nb_retry <= max_retries :
100
+ nb_retry += 1
101
+ time .sleep (nb_retry )
102
+ else :
103
+ e_msg = str (e )
104
+ break
105
+ if e_msg :
106
+ logger .error ('Failed to describe instances %s: %s' % (', ' .join (instance ['InstanceIds' ]), e_msg ))
93
107
continue
94
108
95
109
# For each instance that was successfully launched
You can’t perform that action at this time.
0 commit comments