From 21e9b1132b504dd13c701c24261d99c37b355bce Mon Sep 17 00:00:00 2001 From: phvalguima Date: Mon, 14 Oct 2024 12:55:48 +0200 Subject: [PATCH] Increase logging when index creation fails (#474) This PR will add some extra logging so we can follow-up with any failures due to index creation. --- lib/charms/opensearch/v0/opensearch_relation_provider.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/charms/opensearch/v0/opensearch_relation_provider.py b/lib/charms/opensearch/v0/opensearch_relation_provider.py index 60e1bae62..d8bb76c8d 100644 --- a/lib/charms/opensearch/v0/opensearch_relation_provider.py +++ b/lib/charms/opensearch/v0/opensearch_relation_provider.py @@ -217,12 +217,16 @@ def _on_index_requested(self, event: IndexRequestedEvent) -> None: # noqa try: self.opensearch.request("PUT", f"/{event.index}") except OpenSearchHttpError as e: - if not ( + if ( e.response_code == 400 and e.response_body.get("error", {}).get("type") == "resource_already_exists_exception" ): - logger.error(IndexCreationFailed.format(index=event.index)) + logger.warning("Index failed to be created as it already exists, continuing...") + else: + logger.error( + IndexCreationFailed.format(index=event.index) + f"\nresponse error: {e}" + ) self.charm.status.set(BlockedStatus(IndexCreationFailed.format(index=event.index))) event.defer() return