diff --git a/code/ddns-lambda.py b/code/ddns-lambda.py index da1e662..b4f17f4 100755 --- a/code/ddns-lambda.py +++ b/code/ddns-lambda.py @@ -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') @@ -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", @@ -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()) diff --git a/code/ddns-lambda.zip b/code/ddns-lambda.zip index e91430f..c9458ee 100644 Binary files a/code/ddns-lambda.zip and b/code/ddns-lambda.zip differ