Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
badra001 committed Apr 28, 2023
1 parent 7f7cf3a commit 414a150
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions code/ddns-lambda.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,7 +694,7 @@ def lambda_handler(
f"2.1 instance: {instance_id}, using tag_option.name hostname {tag_data['option_name'].hostname} and and tag_option.name zone {tag_data['option_name'].zonename}")
f_hostname = tag_data['option_name'].hostname
f_zonename = tag_data['option_name'].zonename
# elif not tag_data['option_name'].valid and tag_data['option_name'].hostname and tag_data['option_name'].zonename and all(flags['noforward'], flags['forcename']):
# elif not tag_data['option_name'].valid and tag_data['option_name'].hostname and tag_data['option_name'].zonename and all([flags['noforward'], flags['forcename']]):
# LOGGER.info(
# f"2.2 instance: {instance_id}, using tag_option.name hostname {tag_data['option_name'].hostname} and and tag_option.name zone {tag_data['option_name'].zonename} [noforward,forcename]")
# f_hostname = tag_data['option_name'].hostname
Expand Down Expand Up @@ -1028,7 +1028,7 @@ def lambda_handler(
# create CNAME record in private zone
if state == 'running':
try:
if not flags['nocname'] and (all(emr_status.is_cluster, emr_status.is_master) or not emr_status.is_cluster):
if not flags['nocname'] and (all([emr_status.is_cluster, emr_status.is_master]) or not emr_status.is_cluster):
LOGGER.debug(f"cname_host_name: {cf_hostname} {lineno()}")
LOGGER.debug(f"cname_domain_suffix: {cf_zonename} {lineno()}")
LOGGER.debug(f"cname_domain_suffix_id: {cf_zonename_id} {lineno()}")
Expand Down Expand Up @@ -1068,7 +1068,7 @@ def lambda_handler(
instance_id, str(err) + lineno())

try:
if not flags['noheritage']:
if not flags['noheritage'] and not flags['nocname'] and (all([emr_status.is_cluster, emr_status.is_master]) or not emr_status.is_cluster):
if len(heritage) > 0:
cf_hostname_txt = TXT_RR_PREFIX + '.' + cf_hostname
LOGGER.debug(
Expand Down Expand Up @@ -3308,13 +3308,17 @@ def discover_emr_cluster(tags):
:return (bool,str): Tuple containing is_master, is_cluster, and cluster_id if it's a cluster. cluster_id will be empty if not a cluster.
"""

LOGGER.info(f"discover_emr tags {tags}")
cluster_tuple = namedtuple('EMRCluster', ['is_cluster', 'is_master', 'cluster_id'])
cluster_id = tags.get('aws:elasticmapreduce:job-flow-id', '')
LOGGER.info(f"discover_emr cluster_id {cluster_id}")
is_master = tags.get('aws:elasticmapreduce:instance-group-role', '') == 'MASTER'
LOGGER.info(f"discover_emr is_master {is_master}")
is_cluster = cluster_id != ''
LOGGER.info(f"discover_emr is_cluster {is_cluster}")

result = cluster_tuple(is_cluster, is_master, cluster_id)
LOGGER.debug(f"discover_emr: {str(result)} {lineno()}")
LOGGER.info(f"discover_emr: {str(result)} {lineno()}")
return result


Expand Down

0 comments on commit 414a150

Please sign in to comment.