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

KeyError 'Options' from opensearch module_utils #1907

Closed
1 task done
phene opened this issue Aug 4, 2023 · 4 comments · Fixed by #1910
Closed
1 task done

KeyError 'Options' from opensearch module_utils #1907

phene opened this issue Aug 4, 2023 · 4 comments · Fixed by #1910
Labels
bug This issue/PR relates to a bug module module plugins plugin (any type) python3 traceback

Comments

@phene
Copy link
Contributor

phene commented Aug 4, 2023

Summary

The opensearch module_utils has a function called get_domain_config, which performs the AWS API call DescribeDomainConfig docs here. The function assumes that every property of the response has an Options key, but the ChangeProgressDetails section does not. Because of this, using the opensearch_info modules results in a KeyError.

Buggy code is here

Issue Type

Bug Report

Component Name

opensearch_info
get_domain_config in opensearch module_utils

Ansible Version

Not relevent

Collection Versions

4.5.0+

AWS SDK versions

boto3==1.26.35
botocore==1.29.35

Configuration

n/a

OS / Environment

n/a

Steps to Reproduce

- name: Get OpenSearch domain info
  community.aws.opensearch_info:
    domain_name: "{{ opensearch_domain_name }}"
  register: opensearch_domain_info

Expected Results

Fetches the domain info

Actual Results

  File "/home/localuser/.ansible/tmp/ansible-tmp-1691179537.8669083-2393-273467034050220/AnsiballZ_opensearch_info.py", line 102, in <module>
    _ansiballz_main()
  File "/home/localuser/.ansible/tmp/ansible-tmp-1691179537.8669083-2393-273467034050220/AnsiballZ_opensearch_info.py", line 94, in _ansiballz_main
    invoke_module(zipped_mod, temp_path, ANSIBALLZ_PARAMS)
  File "/home/localuser/.ansible/tmp/ansible-tmp-1691179537.8669083-2393-273467034050220/AnsiballZ_opensearch_info.py", line 40, in invoke_module
    runpy.run_module(mod_name='ansible_collections.community.aws.plugins.modules.opensearch_info', init_globals=None, run_name='__main__', alter_sys=True)
  File "/usr/lib/python3.7/runpy.py", line 205, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/lib/python3.7/runpy.py", line 96, in _run_module_code
    mod_name, mod_spec, pkg_name, script_name)
  File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.aws.opensearch_info_payload_h7ih8g0o/ansible_community.aws.opensearch_info_payload.zip/ansible_collections/community/aws/plugins/modules/opensearch_info.py", line 530, in <module>
  File "/tmp/ansible_community.aws.opensearch_info_payload_h7ih8g0o/ansible_community.aws.opensearch_info_payload.zip/ansible_collections/community/aws/plugins/modules/opensearch_info.py", line 526, in main
  File "/tmp/ansible_community.aws.opensearch_info_payload_h7ih8g0o/ansible_community.aws.opensearch_info_payload.zip/ansible_collections/community/aws/plugins/modules/opensearch_info.py", line 502, in domain_info
  File "/tmp/ansible_community.aws.opensearch_info_payload_h7ih8g0o/ansible_community.aws.opensearch_info_payload.zip/ansible_collections/community/aws/plugins/module_utils/opensearch.py", line 63, in get_domain_config
KeyError: 'Options'

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibullbot
Copy link

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

@ansibullbot
Copy link

@ansibullbot ansibullbot added bug This issue/PR relates to a bug module module needs_triage plugins plugin (any type) python3 traceback labels Aug 4, 2023
@RonneGisun
Copy link

RonneGisun commented Aug 20, 2023

Same result for all examples (https://docs.ansible.com/ansible/latest//collections/community/aws/opensearch_info_module.html#examples)
Python 3.10
community.aws 5.5.0

- name: Get all OpenSearch instances that have the specified Doamin Name
  community.aws.opensearch_info:
    region: "{{ application_region }}"
    domain_name: "{{ aws_opensearch_domain_name }}"

- name: Get all OpenSearch instances
  community.aws.opensearch_info:
    region: "{{ application_region }}"

- name: Get all OpenSearch instances that have the specified Key, Value tags
  community.aws.opensearch_info:
    region: "{{ application_region }}"
    tags:
      Application: "{{ application_name }}"
      Environment: "{{ application_environment }}"
The full traceback is:
Traceback (most recent call last):
  File "<stdin>", line 107, in <module>
  File "<stdin>", line 99, in _ansiballz_main
  File "<stdin>", line 47, in invoke_module
  File "/usr/local/lib/python3.10/runpy.py", line 224, in run_module
    return _run_module_code(code, init_globals, run_name, mod_spec)
  File "/usr/local/lib/python3.10/runpy.py", line 96, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/usr/local/lib/python3.10/runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "/tmp/ansible_community.aws.opensearch_info_payload_bacvlzh4/ansible_community.aws.opensearch_info_payload.zip/ansible_collections/community/aws/plugins/modules/opensearch_info.py", line 531, in <module>
  File "/tmp/ansible_community.aws.opensearch_info_payload_bacvlzh4/ansible_community.aws.opensearch_info_payload.zip/ansible_collections/community/aws/plugins/modules/opensearch_info.py", line 527, in main
  File "/tmp/ansible_community.aws.opensearch_info_payload_bacvlzh4/ansible_community.aws.opensearch_info_payload.zip/ansible_collections/community/aws/plugins/modules/opensearch_info.py", line 503, in domain_info
  File "/tmp/ansible_community.aws.opensearch_info_payload_bacvlzh4/ansible_community.aws.opensearch_info_payload.zip/ansible_collections/community/aws/plugins/module_utils/opensearch.py", line 63, in get_domain_config
KeyError: 'Options'

@markuman
Copy link
Member

markuman commented Aug 21, 2023

ref #1910

softwarefactory-project-zuul bot pushed a commit that referenced this issue Aug 31, 2023
opensearch: avoid a KeyError during the DomainConfig reading

This commit avoids a KeyError exception in get_domain_config().
Some entries from DomainConfig don't have any Options key. For instance, ChangeProgressDetails.
See:

https://docs.aws.amazon.com/opensearch-service/latest/APIReference/API_DomainConfig.html
https://docs.aws.amazon.com/opensearch-service/latest/APIReference/API_ChangeProgressDetails.html

Closes: #1907

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis
patchback bot pushed a commit that referenced this issue Aug 31, 2023
opensearch: avoid a KeyError during the DomainConfig reading

This commit avoids a KeyError exception in get_domain_config().
Some entries from DomainConfig don't have any Options key. For instance, ChangeProgressDetails.
See:

https://docs.aws.amazon.com/opensearch-service/latest/APIReference/API_DomainConfig.html
https://docs.aws.amazon.com/opensearch-service/latest/APIReference/API_ChangeProgressDetails.html

Closes: #1907

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis
(cherry picked from commit 9a9c8c5)
patchback bot pushed a commit that referenced this issue Aug 31, 2023
opensearch: avoid a KeyError during the DomainConfig reading

This commit avoids a KeyError exception in get_domain_config().
Some entries from DomainConfig don't have any Options key. For instance, ChangeProgressDetails.
See:

https://docs.aws.amazon.com/opensearch-service/latest/APIReference/API_DomainConfig.html
https://docs.aws.amazon.com/opensearch-service/latest/APIReference/API_ChangeProgressDetails.html

Closes: #1907

Reviewed-by: Markus Bergholz <[email protected]>
Reviewed-by: Alina Buzachis
(cherry picked from commit 9a9c8c5)
softwarefactory-project-zuul bot pushed a commit that referenced this issue Sep 1, 2023
…1923)

[PR #1910/9a9c8c58 backport][stable-6] opensearch: avoid a KeyError during the DomainConfig reading

This is a backport of PR #1910 as merged into main (9a9c8c5).
This commit avoids a KeyError exception in get_domain_config().
Some entries from DomainConfig don't have any Options key. For instance, ChangeProgressDetails.
See:

https://docs.aws.amazon.com/opensearch-service/latest/APIReference/API_DomainConfig.html
https://docs.aws.amazon.com/opensearch-service/latest/APIReference/API_ChangeProgressDetails.html

Closes: #1907

Reviewed-by: Alina Buzachis
softwarefactory-project-zuul bot pushed a commit that referenced this issue Sep 1, 2023
…1922)

[PR #1910/9a9c8c58 backport][stable-5] opensearch: avoid a KeyError during the DomainConfig reading

This is a backport of PR #1910 as merged into main (9a9c8c5).
This commit avoids a KeyError exception in get_domain_config().
Some entries from DomainConfig don't have any Options key. For instance, ChangeProgressDetails.
See:

https://docs.aws.amazon.com/opensearch-service/latest/APIReference/API_DomainConfig.html
https://docs.aws.amazon.com/opensearch-service/latest/APIReference/API_ChangeProgressDetails.html

Closes: #1907

Reviewed-by: Alina Buzachis
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 module module plugins plugin (any type) python3 traceback
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants