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 #929/0b97186c backport][stable-4] elbv2 - Fix KeyError when passing two TGs #933

Conversation

patchback[bot]
Copy link

@patchback patchback bot commented Jul 15, 2022

This is a backport of PR #929 as merged into main (0b97186).

SUMMARY

Fixes: ansible-collections/community.aws#1089

ISSUE TYPE
  • Bugfix Pull Request
COMPONENT NAME

plugins/module_utils/elbv2.py

ADDITIONAL INFORMATION

Based on the docs, if you want to balance across multiple TGs you shouldn't pass a TargetGroupArn, and instead just the ForwardConfig. (https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/elbv2.html#ElasticLoadBalancingv2.Client.create_listener)

The Amazon Resource Name (ARN) of the target group. Specify only when Type is forward and you want to route to a single target group. To route to one or more target groups, use ForwardConfig instead.

However, it is also valid (but redundant) to Pass the ARN and a ForwardConfig

If you specify both ForwardConfig and TargetGroupArn, you can specify only one target group using ForwardConfig and it must be the same target group specified in TargetGroupArn.

Original Error:

The full traceback is:
Traceback (most recent call last):
  File "/home/alex/.ansible/tmp/ansible-tmp-1650531340.4967074-29141-25081229266719/AnsiballZ_elb_application_lb.py", line 102, in <module>
    _ansiballz_main()
  File "/home/alex/.ansible/tmp/ansible-tmp-1650531340.4967074-29141-25081229266719/AnsiballZ_elb_application_lb.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/alex/.ansible/tmp/ansible-tmp-1650531340.4967074-29141-25081229266719/AnsiballZ_elb_application_lb.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.aws.plugins.modules.elb_application_lb', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.10/runpy.py", line 209, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/community/aws/plugins/modules/elb_application_lb.py", line 821, in <module>
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/community/aws/plugins/modules/elb_application_lb.py", line 815, in main
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/community/aws/plugins/modules/elb_application_lb.py", line 653, in create_or_update_alb
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py", line 928, in compare_rules
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py", line 894, in _compare_rule
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py", line 894, in <listcomp>
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py", line 29, in _prune_ForwardConfig
KeyError: 'TargetGroupArn'

elbv2 - Fix KeyError when passing two TGs

SUMMARY
Fixes: ansible-collections/community.aws#1089
ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME
plugins/module_utils/elbv2.py
ADDITIONAL INFORMATION
Based on the docs, if you want to balance across multiple TGs you shouldn't pass a TargetGroupArn, and instead just the ForwardConfig.  (https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/elbv2.html#ElasticLoadBalancingv2.Client.create_listener)

The Amazon Resource Name (ARN) of the target group. Specify only when Type is forward and you want to route to a single target group. To route to one or more target groups, use ForwardConfig instead.

However, it is also valid (but redundant) to Pass the ARN and a ForwardConfig

If you specify both ForwardConfig and TargetGroupArn, you can specify only one target group using ForwardConfig and it must be the same target group specified in TargetGroupArn.

Original Error:
The full traceback is:
Traceback (most recent call last):
  File "/home/alex/.ansible/tmp/ansible-tmp-1650531340.4967074-29141-25081229266719/AnsiballZ_elb_application_lb.py", line 102, in <module>
    _ansiballz_main()
  File "/home/alex/.ansible/tmp/ansible-tmp-1650531340.4967074-29141-25081229266719/AnsiballZ_elb_application_lb.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/alex/.ansible/tmp/ansible-tmp-1650531340.4967074-29141-25081229266719/AnsiballZ_elb_application_lb.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.aws.plugins.modules.elb_application_lb', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.10/runpy.py", line 209, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/community/aws/plugins/modules/elb_application_lb.py", line 821, in <module>
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/community/aws/plugins/modules/elb_application_lb.py", line 815, in main
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/community/aws/plugins/modules/elb_application_lb.py", line 653, in create_or_update_alb
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py", line 928, in compare_rules
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py", line 894, in _compare_rule
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py", line 894, in <listcomp>
  File "/tmp/ansible_community.aws.elb_application_lb_payload_dy92ctf5/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py", line 29, in _prune_ForwardConfig
KeyError: 'TargetGroupArn'

Reviewed-by: Alina Buzachis <None>
(cherry picked from commit 0b97186)
@ansibullbot ansibullbot added bug This issue/PR relates to a bug community_review module_utils module_utils needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) python3 tests tests traceback labels Jul 15, 2022
@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded.

✔️ ansible-galaxy-importer SUCCESS in 5m 22s
✔️ build-ansible-collection SUCCESS in 5m 53s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 11m 49s
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 12m 13s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 10m 18s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 7m 52s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 7m 10s
✔️ ansible-test-splitter SUCCESS in 3m 18s
⚠️ integration-amazon.aws-1 SKIPPED
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
✔️ integration-community.aws-1 SUCCESS in 10m 17s
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

@tremble tremble added the mergeit Merge the PR (SoftwareFactory) label Jul 15, 2022
@softwarefactory-project-zuul

This comment was marked as outdated.

@tremble
Copy link
Contributor

tremble commented Jul 15, 2022

regate

@softwarefactory-project-zuul
Copy link
Contributor

Build succeeded (gate pipeline).

✔️ ansible-galaxy-importer SUCCESS in 5m 33s
✔️ build-ansible-collection SUCCESS in 5m 51s
✔️ ansible-test-sanity-aws-ansible-python38 SUCCESS in 9m 40s
✔️ ansible-test-sanity-aws-ansible-2.12-python38 SUCCESS in 11m 55s
✔️ ansible-test-sanity-aws-ansible-2.13-python38 SUCCESS in 9m 24s
✔️ ansible-test-units-amazon-aws-python38 SUCCESS in 8m 56s
✔️ ansible-test-units-amazon-aws-python39 SUCCESS in 6m 07s
✔️ ansible-test-splitter SUCCESS in 2m 42s
⚠️ integration-amazon.aws-1 SKIPPED
⚠️ integration-amazon.aws-2 SKIPPED
⚠️ integration-amazon.aws-3 SKIPPED
⚠️ integration-amazon.aws-4 SKIPPED
⚠️ integration-amazon.aws-5 SKIPPED
⚠️ integration-amazon.aws-6 SKIPPED
⚠️ integration-amazon.aws-7 SKIPPED
⚠️ integration-amazon.aws-8 SKIPPED
⚠️ integration-amazon.aws-9 SKIPPED
⚠️ integration-amazon.aws-10 SKIPPED
⚠️ integration-amazon.aws-11 SKIPPED
⚠️ integration-amazon.aws-12 SKIPPED
⚠️ integration-amazon.aws-13 SKIPPED
✔️ integration-community.aws-1 SUCCESS in 9m 06s
⚠️ integration-community.aws-2 SKIPPED
⚠️ integration-community.aws-3 SKIPPED
⚠️ integration-community.aws-4 SKIPPED
⚠️ integration-community.aws-5 SKIPPED
⚠️ integration-community.aws-6 SKIPPED
⚠️ integration-community.aws-7 SKIPPED
⚠️ integration-community.aws-8 SKIPPED
⚠️ integration-community.aws-9 SKIPPED
⚠️ integration-community.aws-10 SKIPPED
⚠️ integration-community.aws-11 SKIPPED
⚠️ integration-community.aws-12 SKIPPED
⚠️ integration-community.aws-13 SKIPPED

@softwarefactory-project-zuul softwarefactory-project-zuul bot merged commit 880e629 into stable-4 Jul 15, 2022
@softwarefactory-project-zuul softwarefactory-project-zuul bot deleted the patchback/backports/stable-4/0b97186c83af537ec58e53531aea55c1997636f0/pr-929 branch July 15, 2022 14:00
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…sible-collections#933)

ec2_asg: Add functionality to detach specified instances from ASG 

SUMMARY

Adds feature to detach specified instances from a AutoScalingGroup rather than terminating them directly.
Detached instances are not terminated and can be managed independently.

Implements ansible-collections#649
ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ec2_asg
ADDITIONAL INFORMATION


Makes use of
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/autoscaling.html#AutoScaling.Client.detach_instances

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Mandar Kulkarni <[email protected]>
Reviewed-by: Jill R <None>
Reviewed-by: Joseph Torcasso <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Sep 18, 2023
…sible-collections#933)

ec2_asg: Add functionality to detach specified instances from ASG 

SUMMARY

Adds feature to detach specified instances from a AutoScalingGroup rather than terminating them directly.
Detached instances are not terminated and can be managed independently.

Implements ansible-collections#649
ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ec2_asg
ADDITIONAL INFORMATION


Makes use of
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/autoscaling.html#AutoScaling.Client.detach_instances

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Mandar Kulkarni <[email protected]>
Reviewed-by: Jill R <None>
Reviewed-by: Joseph Torcasso <None>
abikouo pushed a commit to abikouo/amazon.aws that referenced this pull request Oct 24, 2023
…sible-collections#933)

ec2_asg: Add functionality to detach specified instances from ASG 

SUMMARY

Adds feature to detach specified instances from a AutoScalingGroup rather than terminating them directly.
Detached instances are not terminated and can be managed independently.

Implements ansible-collections#649
ISSUE TYPE


Feature Pull Request

COMPONENT NAME

ec2_asg
ADDITIONAL INFORMATION


Makes use of
https://boto3.amazonaws.com/v1/documentation/api/latest/reference/services/autoscaling.html#AutoScaling.Client.detach_instances

Reviewed-by: Alina Buzachis <None>
Reviewed-by: Mandar Kulkarni <[email protected]>
Reviewed-by: Jill R <None>
Reviewed-by: Joseph Torcasso <None>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue/PR relates to a bug community_review mergeit Merge the PR (SoftwareFactory) module_utils module_utils needs_triage new_contributor Help guide this first time contributor plugins plugin (any type) python3 tests tests traceback
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants