Skip to content

Commit

Permalink
Fix error retry handling for Route53
Browse files Browse the repository at this point in the history
  • Loading branch information
kaidokert committed Mar 10, 2019
1 parent 9bcafa6 commit c925dfe
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions salt/modules/boto_route53.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ def _get_split_zone(zone, _conn, private_zone):
return False


def _is_retryable_error(exception):
return exception.code not in ['SignatureDoesNotMatch']


def describe_hosted_zones(zone_id=None, domain_name=None, region=None,
key=None, keyid=None, profile=None):
'''
Expand Down Expand Up @@ -270,7 +274,7 @@ def zone_exists(zone, region=None, key=None, keyid=None, profile=None,
return bool(conn.get_zone(zone))

except DNSServerError as e:
if retry_on_errors:
if retry_on_errors and _is_retryable_error(e):
if 'Throttling' == e.code:
log.debug('Throttled by AWS API.')
elif 'PriorRequestNotComplete' == e.code:
Expand Down Expand Up @@ -426,7 +430,7 @@ def create_healthcheck(ip_addr=None, fqdn=None, region=None, key=None, keyid=Non
return {'result': conn.create_health_check(hc_)}
except DNSServerError as exc:
log.debug(exc)
if retry_on_errors:
if retry_on_errors and _is_retryable_error(exc):
if 'Throttling' == exc.code:
log.debug('Throttled by AWS API.')
elif 'PriorRequestNotComplete' == exc.code:
Expand Down Expand Up @@ -519,7 +523,7 @@ def get_record(name, zone, record_type, fetch_all=False, region=None, key=None,
break # the while True

except DNSServerError as e:
if retry_on_errors:
if retry_on_errors and _is_retryable_error(e):
if 'Throttling' == e.code:
log.debug('Throttled by AWS API.')
elif 'PriorRequestNotComplete' == e.code:
Expand Down Expand Up @@ -594,7 +598,7 @@ def add_record(name, value, zone, record_type, identifier=None, ttl=None,
break

except DNSServerError as e:
if retry_on_errors:
if retry_on_errors and _is_retryable_error(e):
if 'Throttling' == e.code:
log.debug('Throttled by AWS API.')
elif 'PriorRequestNotComplete' == e.code:
Expand All @@ -615,7 +619,7 @@ def add_record(name, value, zone, record_type, identifier=None, ttl=None,
return _wait_for_sync(status.id, conn, wait_for_sync)

except DNSServerError as e:
if retry_on_errors:
if retry_on_errors and _is_retryable_error(e):
if 'Throttling' == e.code:
log.debug('Throttled by AWS API.')
elif 'PriorRequestNotComplete' == e.code:
Expand Down Expand Up @@ -677,7 +681,7 @@ def update_record(name, value, zone, record_type, identifier=None, ttl=None,
return _wait_for_sync(status.id, conn, wait_for_sync)

except DNSServerError as e:
if retry_on_errors:
if retry_on_errors and _is_retryable_error(e):
if 'Throttling' == e.code:
log.debug('Throttled by AWS API.')
elif 'PriorRequestNotComplete' == e.code:
Expand Down Expand Up @@ -738,7 +742,7 @@ def delete_record(name, zone, record_type, identifier=None, all_records=False,
return _wait_for_sync(status.id, conn, wait_for_sync)

except DNSServerError as e:
if retry_on_errors:
if retry_on_errors and _is_retryable_error(e):
if 'Throttling' == e.code:
log.debug('Throttled by AWS API.')
elif 'PriorRequestNotComplete' == e.code:
Expand Down

0 comments on commit c925dfe

Please sign in to comment.