Skip to content

Commit

Permalink
Use status from response to determine state of credential report
Browse files Browse the repository at this point in the history
  • Loading branch information
gsoltis committed Mar 25, 2021
1 parent 35addb0 commit 338e516
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions introspector/aws/iam.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,17 +67,20 @@ def _import_credential_report(proxy: ServiceProxy, spec: ServiceSpec):
init_attempts = 0
while not started:
try:
proxy.get('generate_credential_report')
started = True
resp = proxy.get('generate_credential_report')
started = resp.get('State') in ('STARTED', 'COMPLETE')
except ClientError as e:
code = e.response.get('Error', {}).get('Code')
is_throttled = code == 'Throttling'
# If we're throttled, we've at least kicked it off already
if not is_throttled:
_log.error('credential report error', exc_info=e)
raise
else:
started = True
# wait and try again?
init_attempts += 1
if init_attempts >= 3:
_log.error('credential report error', exc_info=e)
raise GFError('Failed to generate credential report')
time.sleep(0.1)
except SSLError:
# wait and try again?
init_attempts += 1
Expand Down

0 comments on commit 338e516

Please sign in to comment.