Skip to content

Commit 338e516

Browse files
committed
Use status from response to determine state of credential report
1 parent 35addb0 commit 338e516

1 file changed

Lines changed: 8 additions & 5 deletions

File tree

introspector/aws/iam.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,17 +67,20 @@ def _import_credential_report(proxy: ServiceProxy, spec: ServiceSpec):
6767
init_attempts = 0
6868
while not started:
6969
try:
70-
proxy.get('generate_credential_report')
71-
started = True
70+
resp = proxy.get('generate_credential_report')
71+
started = resp.get('State') in ('STARTED', 'COMPLETE')
7272
except ClientError as e:
7373
code = e.response.get('Error', {}).get('Code')
7474
is_throttled = code == 'Throttling'
75-
# If we're throttled, we've at least kicked it off already
7675
if not is_throttled:
7776
_log.error('credential report error', exc_info=e)
7877
raise
79-
else:
80-
started = True
78+
# wait and try again?
79+
init_attempts += 1
80+
if init_attempts >= 3:
81+
_log.error('credential report error', exc_info=e)
82+
raise GFError('Failed to generate credential report')
83+
time.sleep(0.1)
8184
except SSLError:
8285
# wait and try again?
8386
init_attempts += 1

0 commit comments

Comments
 (0)