Limit dns queries to 10 attempts

This commit is contained in:
Curtis Castrapel 2018-06-13 15:14:48 -07:00
parent 284e57ad68
commit 14b8892cce
1 changed files with 4 additions and 1 deletions

View File

@ -41,12 +41,15 @@ def _has_dns_propagated(name, token):
def wait_for_dns_change(change_id, account_number=None): def wait_for_dns_change(change_id, account_number=None):
fqdn, token = change_id fqdn, token = change_id
while True: number_of_attempts = 10
for attempts in range(0, number_of_attempts):
status = _has_dns_propagated(fqdn, token) status = _has_dns_propagated(fqdn, token)
current_app.logger.debug("Record status for fqdn: {}: {}".format(fqdn, status)) current_app.logger.debug("Record status for fqdn: {}: {}".format(fqdn, status))
if status: if status:
break break
time.sleep(20) time.sleep(20)
if not status:
raise Exception("Unable to query DNS token for fqdn {}.".format(fqdn))
return return