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
…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
  • Loading branch information
patchback[bot] authored Sep 1, 2023
1 parent c6c8745 commit 348930a
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 348930a

Please sign in to comment.