Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Apr 27, 2023
1 parent 528e9f7 commit 1f6a02a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 16 deletions.
49 changes: 33 additions & 16 deletions code/ddns-lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
LOGGER = logging.getLogger()
account_id = None
region = None
VERSION = '1.2.0b70'
VERSION = '1.2.0b71'

# Read Env variables
DEBUG_LOG_LEVEL = os.environ.get('DebugLogLevel', 'INFO')
Expand Down Expand Up @@ -1668,24 +1668,39 @@ def new_change_resource_recordset(oclient, instance_id, zone_id, host_name, host
LOGGER.debug("change_resource_record_sets UPSERT returned without error - response: %s",
str(update_response) + lineno())
break
except ClientError as err:
LOGGER.info(
f"exception: {instance_id} err {err} sys.exc_info {sys.exc_info()[0]} {sys.exc_info()[1]} {lineno()}")
if 'NoSuchHostedZone' in str(err) and 'No hosted zone found with ID' in str(err):
LOGGER.error("Hosted zone not found error: %s", str(err) + lineno())
# except ClientError as err:
# LOGGER.info(
# f"exception: {instance_id} err {err} sys.exc_info {sys.exc_info()[0]} {sys.exc_info()[1]} {lineno()}")
except Route53.Client.exceptions.NoSuchHostedZone as err:


# if 'NoSuchHostedZone' in str(err) and 'No hosted zone found with ID' in str(err):
3 LOGGER.error("Hosted zone not found error: %s", str(err) + lineno())
LOGGER.info(
f"exception: NoSuchHostedZone {err} sys.exc_info {sys.exc_info()[0]} {sys.exc_info()[1]} {lineno()}")
update_response = "NoSuchHostedZone"
break
elif 'InvalidChangeBatch' in str(err) and 'is not permitted in zone' in str(err):
LOGGER.error(
"Cannot create record - most likely wrong zone name specified: %s", str(err) + lineno())
update_response = "InvalidChangeBatch-WrongZoneName"
except Route53.Client.exceptions.InvalidChangeBatch as err:
# elif 'InvalidChangeBatch' in str(err) and 'is not permitted in zone' in str(err):
# LOGGER.error(
# "Cannot create record - most likely wrong zone name specified: %s", str(err) + lineno())
# update_response = "InvalidChangeBatch-WrongZoneName"
LOGGER.info(f"exception: InvalidChangeBatch {err} sys.exc_info {sys.exc_info()[0]} {sys.exc_info()[1]} {lineno()}")
update_response = "InvalidChangeBatch"
break
elif "(Throttling)" in str(err):
LOGGER.debug("change_resource_record_sets UPSERT throttled due to API limit, retrying: %s", str(
err) + lineno())
else:
LOGGER.info(
f"instance: {instance_id} unexpected error: {err} sys.exc_info {sys.exc_info()[0]} {sys.exc_info()[1]} {lineno()}")
except Route53.Client.exceptions.InvalidInput as err:
LOGGER.info(f"exception: InvalidInput {err} sys.exc_info {sys.exc_info()[0]} {sys.exc_info()[1]} {lineno()}")
update_response = "InvalidInput"
break
except Route53.Client.exceptions.PriorRequestNotComplete as err:
# elif "(Throttling)" in str(err):
LOGGER.info(f"exception: PriorRequestNotComplete {err} sys.exc_info {sys.exc_info()[0]} {sys.exc_info()[1]} {lineno()}")
# LOGGER.debug("change_resource_record_sets UPSERT throttled due to API limit, retrying: %s", str(err) + lineno())
# else:
# LOGGER.info(
# f"instance: {instance_id} unexpected error: {err} sys.exc_info {sys.exc_info()[0]} {sys.exc_info()[1]} {lineno()}")
except Exception as err:
LOGGER.info(f"exception: Exception {err} sys.exc_info {sys.exc_info()[0]} {sys.exc_info()[1]} {lineno()}")

i += 1
LOGGER.info("instance: %s, change_resource_record_sets UPSERT returned error, waiting before retry. %s",
Expand All @@ -1695,6 +1710,8 @@ def new_change_resource_recordset(oclient, instance_id, zone_id, host_name, host
count['sleep.time'] += i
count['retry'] += 1



if i >= MAX_API_RETRY:
LOGGER.error("instance: %s, change_resource_record_sets exceeded max retry of %s",
instance_id, str(MAX_API_RETRY) + lineno())
Expand Down
Binary file modified code/ddns-lambda.zip
Binary file not shown.

0 comments on commit 1f6a02a

Please sign in to comment.