Skip to content

Commit

Permalink
Increase logging when index creation fails (#474)
Browse files Browse the repository at this point in the history
This PR will add some extra logging so we can follow-up with any failures due to index creation.
  • Loading branch information
phvalguima authored Oct 14, 2024
1 parent 3bc81d7 commit 21e9b11
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions lib/charms/opensearch/v0/opensearch_relation_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 21e9b11

Please sign in to comment.