Skip to content

Commit

Permalink
opensearch: avoid a KeyError during the DomainConfig reading (#1910)
Browse files Browse the repository at this point in the history
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)
  • Loading branch information
goneri authored and patchback[bot] committed Aug 31, 2023
1 parent c6c8745 commit 7ef8ce9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions changelogs/fragments/opensearch_domainconfig_no_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfixes:
- "opensearch - Don't try to read a non existing key from the domain config (https://github.com/ansible-collections/community.aws/pull/1910)."
3 changes: 2 additions & 1 deletion plugins/module_utils/opensearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ def get_domain_config(client, module, domain_name):
arn = None
if response is not None:
for k in response["DomainConfig"]:
domain_config[k] = response["DomainConfig"][k]["Options"]
if "Options" in response["DomainConfig"][k]:
domain_config[k] = response["DomainConfig"][k]["Options"]
domain_config["DomainName"] = domain_name
# If ES cluster is attached to the Internet, the "VPCOptions" property is not present.
if "VPCOptions" in domain_config:
Expand Down

0 comments on commit 7ef8ce9

Please sign in to comment.