Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PR #1768/d1c5f053 backport][stable-6] elb_application_lb_info - ensure queries for additional ALB data have retries enabled #1775

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
bugfixes:
- elb_application_lb_info - ensure all API queries use the retry decorator (https://github.com/ansible-collections/amazon.aws/issues/1767).
minor_changes:
- elb_application_lb_info - drop redundant ``describe_load_balancers`` call fetching ``ip_address_type`` (https://github.com/ansible-collections/amazon.aws/pull/1768).
40 changes: 18 additions & 22 deletions plugins/modules/elb_application_lb_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,23 +232,31 @@ def get_paginator(connection, **kwargs):

def get_alb_listeners(connection, module, alb_arn):
try:
return connection.describe_listeners(LoadBalancerArn=alb_arn)["Listeners"]
return connection.describe_listeners(
aws_retry=True,
LoadBalancerArn=alb_arn,
)["Listeners"]
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="Failed to describe alb listeners")


def get_listener_rules(connection, module, listener_arn):
try:
return connection.describe_rules(ListenerArn=listener_arn)["Rules"]
return connection.describe_rules(
aws_retry=True,
ListenerArn=listener_arn,
)["Rules"]
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="Failed to describe listener rules")


def get_load_balancer_attributes(connection, module, load_balancer_arn):
try:
load_balancer_attributes = boto3_tag_list_to_ansible_dict(
connection.describe_load_balancer_attributes(LoadBalancerArn=load_balancer_arn)["Attributes"]
)
attributes = connection.describe_load_balancer_attributes(
aws_retry=True,
LoadBalancerArn=load_balancer_arn,
)["Attributes"]
load_balancer_attributes = boto3_tag_list_to_ansible_dict(attributes)
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="Failed to describe load balancer attributes")

Expand All @@ -262,22 +270,15 @@ def get_load_balancer_attributes(connection, module, load_balancer_arn):

def get_load_balancer_tags(connection, module, load_balancer_arn):
try:
return boto3_tag_list_to_ansible_dict(
connection.describe_tags(ResourceArns=[load_balancer_arn])["TagDescriptions"][0]["Tags"]
)
tag_descriptions = connection.describe_tags(
aws_retry=True,
ResourceArns=[load_balancer_arn],
)["TagDescriptions"]
return boto3_tag_list_to_ansible_dict(tag_descriptions[0]["Tags"])
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="Failed to describe load balancer tags")


def get_load_balancer_ipaddresstype(connection, module, load_balancer_arn):
try:
return connection.describe_load_balancers(LoadBalancerArns=[load_balancer_arn])["LoadBalancers"][0][
"IpAddressType"
]
except (botocore.exceptions.ClientError, botocore.exceptions.BotoCoreError) as e:
module.fail_json_aws(e, msg="Failed to describe load balancer ip address type")


def list_load_balancers(connection, module):
load_balancer_arns = module.params.get("load_balancer_arns")
names = module.params.get("names")
Expand Down Expand Up @@ -308,11 +309,6 @@ def list_load_balancers(connection, module):
for listener in load_balancer["listeners"]:
listener["rules"] = get_listener_rules(connection, module, listener["ListenerArn"])

# Get ALB ip address type
load_balancer["IpAddressType"] = get_load_balancer_ipaddresstype(
connection, module, load_balancer["LoadBalancerArn"]
)

# Turn the boto3 result in to ansible_friendly_snaked_names
snaked_load_balancers = [
camel_dict_to_snake_dict(load_balancer) for load_balancer in load_balancers["LoadBalancers"]
Expand Down