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

Exception modifying rule with existing HttpRequestMethodConfig #187

Closed
bradleypettit opened this issue Nov 2, 2020 · 3 comments · Fixed by #188
Closed

Exception modifying rule with existing HttpRequestMethodConfig #187

bradleypettit opened this issue Nov 2, 2020 · 3 comments · Fixed by #188
Assignees
Labels
bug This issue/PR relates to a bug has_pr module_utils module_utils plugins plugin (any type) python3 traceback

Comments

@bradleypettit
Copy link
Contributor

SUMMARY

Using community.aws.elb_application_lb we have found that you are not able to modify existing routing rules if the condition field is 'http-request-method'. It is possible to create/update an ALB and add a rule using http-request-method in the first instance. However any subsequent executions of the same task, or trying to modify the routing rule, result in a KeyError exception. As shown below, community.aws.elb_application_lb is relying on the elbv2 module_util to compare the rule conditions.

ISSUE TYPE
  • Bug Report
COMPONENT NAME

elbv2.py

ANSIBLE VERSION
ansible 2.10.2
  config file = /etc/ansible/ansible.cfg
  configured module search path = ['/home/bradley/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/bradley/.local/lib/python3.8/site-packages/ansible
  executable location = /home/bradley/.local/bin/ansible
  python version = 3.8.5 (default, Jul 28 2020, 12:59:40) [GCC 9.3.0]
CONFIGURATION
N/A
OS / ENVIRONMENT
NAME="Ubuntu"
VERSION="20.04.1 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.1 LTS"
VERSION_ID="20.04"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
STEPS TO REPRODUCE
---
- hosts: localhost
  tasks:
    - community.aws.elb_application_lb:
        name: test-application-load-balancer
        state: present
        security_groups:
          - sg-group #masked
        subnets:
          - subnet-a #masked
          - subnet-b #masked
          - subnet-c #masked
        listeners:
          - Protocol: HTTP
            Port: 80
            DefaultActions:
              - Type: fixed-response
                FixedResponseConfig:
                  StatusCode: "200"
            Rules:
              - Conditions:
                  - Field: http-request-method
                    HttpRequestMethodConfig:
                      Values:
                        - 'GET'
                Priority: '1'
                Actions:
                  - Type: fixed-response
                    FixedResponseConfig:
                      StatusCode: "200"        
EXPECTED RESULTS

It's expected that the above task would in the first instance create a new load balancer, and on subsequent runs execute successfully with no changes.

ACTUAL RESULTS
The full traceback is:
Traceback (most recent call last):
  File "/home/bradley/.ansible/tmp/ansible-tmp-1604317711.9949253-1774-237985700272502/AnsiballZ_elb_application_lb.py", line 102, in <module>
    _ansiballz_main()
  File "/home/bradley/.ansible/tmp/ansible-tmp-1604317711.9949253-1774-237985700272502/AnsiballZ_elb_application_lb.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/bradley/.ansible/tmp/ansible-tmp-1604317711.9949253-1774-237985700272502/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.8/runpy.py", line 207, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.8/runpy.py", line 97, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.aws.elb_application_lb_payload_mxyup0n8/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/community/aws/plugins/modules/elb_application_lb.py", line 665, in <module>
  File "/tmp/ansible_community.aws.elb_application_lb_payload_mxyup0n8/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/community/aws/plugins/modules/elb_application_lb.py", line 659, in main
  File "/tmp/ansible_community.aws.elb_application_lb_payload_mxyup0n8/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/community/aws/plugins/modules/elb_application_lb.py", line 544, in create_or_update_elb
  File "/tmp/ansible_community.aws.elb_application_lb_payload_mxyup0n8/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py", line 816, in compare_rules
  File "/tmp/ansible_community.aws.elb_application_lb_payload_mxyup0n8/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py", line 791, in _compare_rule
  File "/tmp/ansible_community.aws.elb_application_lb_payload_mxyup0n8/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py", line 727, in _compare_condition
KeyError: 'Values'
fatal: [localhost]: FAILED! => {
    "changed": false,
    "module_stderr": "Traceback (most recent call last):\n  File \"/home/bradley/.ansible/tmp/ansible-tmp-1604317711.9949253-1774-237985700272502/AnsiballZ_elb_application_lb.py\", line 102, in <module>\n    _ansiballz_main()\n  File \"/home/bradley/.ansible/tmp/ansible-tmp-1604317711.9949253-1774-237985700272502/AnsiballZ_elb_application_lb.py\", line 94, in _ansiballz_main\n    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)\n  File \"/home/bradley/.ansible/tmp/ansible-tmp-1604317711.9949253-1774-237985700272502/AnsiballZ_elb_application_lb.py\", line 40, in invoke_module\n    runpy.run_module(mod_name='ansible_collections.community.aws.plugins.modules.elb_application_lb', init_globals=None, run_name='__main__', alter_sys=True)\n  File \"/usr/lib/python3.8/runpy.py\", line 207, in run_module\n    return _run_module_code(code, init_globals, run_name, mod_spec)\n  File \"/usr/lib/python3.8/runpy.py\", line 97, in _run_module_code\n    _run_code(code, mod_globals, init_globals,\n  File \"/usr/lib/python3.8/runpy.py\", line 87, in _run_code\n    exec(code, run_globals)\n  File \"/tmp/ansible_community.aws.elb_application_lb_payload_mxyup0n8/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/community/aws/plugins/modules/elb_application_lb.py\", line 665, in <module>\n  File \"/tmp/ansible_community.aws.elb_application_lb_payload_mxyup0n8/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/community/aws/plugins/modules/elb_application_lb.py\", line 659, in main\n  File \"/tmp/ansible_community.aws.elb_application_lb_payload_mxyup0n8/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/community/aws/plugins/modules/elb_application_lb.py\", line 544, in create_or_update_elb\n  File \"/tmp/ansible_community.aws.elb_application_lb_payload_mxyup0n8/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py\", line 816, in compare_rules\n  File \"/tmp/ansible_community.aws.elb_application_lb_payload_mxyup0n8/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py\", line 791, in _compare_rule\n  File \"/tmp/ansible_community.aws.elb_application_lb_payload_mxyup0n8/ansible_community.aws.elb_application_lb_payload.zip/ansible_collections/amazon/aws/plugins/module_utils/elbv2.py\", line 727, in _compare_condition\nKeyError: 'Values'\n",
    "module_stdout": "",
    "msg": "MODULE FAILURE\nSee stdout/stderr for the exact error",
    "rc": 1
}
@bradleypettit
Copy link
Contributor Author

Additional Issue Summary

I looked into this issue some more and have found that it actually impacts multiple rule configurations, including http-header, http-request-method, host-header, path-pattern, and query-string. I noticed that there was already a special condition for when 'SourceIpConfig' is present, so source-ip is not impacted.

Note that host-header and path-pattern fields can be defined using Values directly, without HostHeaderConfig or PathPatternConfig. This may be why the issue has not already been addressed. When using HostHeaderConfig/PathPatternConfig though, they have the same issue.

Related Material

Similar issue with http-header config.
Boto Reference: ElasticLoadBalancingv2.Client.create_rule

Expanded Steps to Reproduce

See sample playbook at https://gist.github.com/bradleypettit/351d5a1c576eba826bbafd2f016550c9. There is a task for each Rule field mentioned above. Each task runs twice, the first successfully creates the ALB, and the second execution fails with KeyError.

@gravesm
Copy link
Member

gravesm commented Dec 18, 2020

Closing as this is duplicate of ansible-collections/community.aws#117.

@gravesm
Copy link
Member

gravesm commented Dec 18, 2020

Thank you for reporting the issue @bradleypettit

@gravesm gravesm reopened this Dec 18, 2020
@gravesm gravesm added the needs_verified Some one might want to take a look at this and reproduce it to confirm label Dec 18, 2020
goneri added a commit to goneri/community.aws that referenced this issue Jan 7, 2021
@goneri goneri removed the needs_verified Some one might want to take a look at this and reproduce it to confirm label Jan 8, 2021
@ansibullbot ansibullbot added bug This issue/PR relates to a bug has_pr module_utils module_utils needs_triage plugins plugin (any type) python3 traceback labels Jan 13, 2021
goneri added a commit to goneri/community.aws that referenced this issue Jan 19, 2021
tremble pushed a commit to goneri/community.aws that referenced this issue Mar 16, 2021
tremble added a commit to ansible-collections/community.aws that referenced this issue Mar 16, 2021
* elb_application_lb: test a rule based on http-header

This should initially fail and be fixed the day ansible-collections/amazon.aws#188
is merged.

See: ansible-collections/amazon.aws#187
See: #117


Co-authored-by: Mark Chappell <[email protected]>
jillr pushed a commit to jillr/amazon.aws that referenced this issue May 3, 2021
…ble-collections#187)

* Split imports into a single line

* Increase the max_attempts retries for the ec2_instance tests, we're running a *lot* in parallel which triggers RateLimiting errors
jillr pushed a commit to jillr/amazon.aws that referenced this issue May 10, 2021
…ble-collections#187)

* Split imports into a single line

* Increase the max_attempts retries for the ec2_instance tests, we're running a *lot* in parallel which triggers RateLimiting errors
jillr pushed a commit to jillr/amazon.aws that referenced this issue May 10, 2021
…ble-collections#187)

* Split imports into a single line

* Increase the max_attempts retries for the ec2_instance tests, we're running a *lot* in parallel which triggers RateLimiting errors
jillr pushed a commit to jillr/amazon.aws that referenced this issue May 13, 2021
…ble-collections#187)

* Split imports into a single line

* Increase the max_attempts retries for the ec2_instance tests, we're running a *lot* in parallel which triggers RateLimiting errors
danquixote pushed a commit to danquixote/community.aws that referenced this issue May 16, 2021
…ions#347)

* elb_application_lb: test a rule based on http-header

This should initially fail and be fixed the day ansible-collections/amazon.aws#188
is merged.

See: ansible-collections/amazon.aws#187
See: ansible-collections#117


Co-authored-by: Mark Chappell <[email protected]>
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this issue Jul 19, 2021
…ions#347)

* elb_application_lb: test a rule based on http-header

This should initially fail and be fixed the day ansible-collections/amazon.aws#188
is merged.

See: ansible-collections/amazon.aws#187
See: ansible-collections#117


Co-authored-by: Mark Chappell <[email protected]>
alinabuzachis pushed a commit to alinabuzachis/community.aws that referenced this issue Jul 19, 2021
…ions#347)

* elb_application_lb: test a rule based on http-header

This should initially fail and be fixed the day ansible-collections/amazon.aws#188
is merged.

See: ansible-collections/amazon.aws#187
See: ansible-collections#117


Co-authored-by: Mark Chappell <[email protected]>
danielcotton pushed a commit to danielcotton/community.aws that referenced this issue Nov 23, 2021
…ions#347)

* elb_application_lb: test a rule based on http-header

This should initially fail and be fixed the day ansible-collections/amazon.aws#188
is merged.

See: ansible-collections/amazon.aws#187
See: ansible-collections#117


Co-authored-by: Mark Chappell <[email protected]>
goneri added a commit that referenced this issue Sep 20, 2022
* elb_application_lb: test a rule based on http-header

This should initially fail and be fixed the day #188
is merged.

See: #187
See: ansible-collections/community.aws#117

Co-authored-by: Mark Chappell <[email protected]>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@8c0ea48
GomathiselviS pushed a commit to GomathiselviS/amazon.aws that referenced this issue Sep 20, 2022
…ions#347)

* elb_application_lb: test a rule based on http-header

This should initially fail and be fixed the day ansible-collections#188
is merged.

See: ansible-collections#187
See: ansible-collections/community.aws#117

Co-authored-by: Mark Chappell <[email protected]>

This commit was initially merged in https://github.com/ansible-collections/community.aws
See: ansible-collections/community.aws@8c0ea48
abikouo pushed a commit to abikouo/amazon.aws that referenced this issue Sep 18, 2023
…ble-collections#187)

* Split imports into a single line

* Increase the max_attempts retries for the ec2_instance tests, we're running a *lot* in parallel which triggers RateLimiting errors
abikouo pushed a commit to abikouo/amazon.aws that referenced this issue Sep 18, 2023
…ble-collections#187)

* Split imports into a single line

* Increase the max_attempts retries for the ec2_instance tests, we're running a *lot* in parallel which triggers RateLimiting errors
abikouo pushed a commit to abikouo/amazon.aws that referenced this issue Oct 24, 2023
…ble-collections#187)

* Split imports into a single line

* Increase the max_attempts retries for the ec2_instance tests, we're running a *lot* in parallel which triggers RateLimiting errors
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 has_pr module_utils module_utils plugins plugin (any type) python3 traceback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants