From cb4c2128fd4273049f4453026e1d72b374f87ecc Mon Sep 17 00:00:00 2001 From: Carl Csaposs Date: Mon, 22 Apr 2024 23:34:10 +0000 Subject: [PATCH] Add handling for HTTP request failure when acquiring lock (#247) --- lib/charms/opensearch/v0/opensearch_locking.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/charms/opensearch/v0/opensearch_locking.py b/lib/charms/opensearch/v0/opensearch_locking.py index 36b54ef5b..d560a7d9f 100644 --- a/lib/charms/opensearch/v0/opensearch_locking.py +++ b/lib/charms/opensearch/v0/opensearch_locking.py @@ -278,7 +278,11 @@ def acquired(self) -> bool: # noqa: C901 else: logger.exception("Error creating OpenSearch lock document") return False - unit = self._unit_with_lock(host) + try: + unit = self._unit_with_lock(host) + except OpenSearchHttpError: + logger.exception("Error checking which unit has OpenSearch lock") + return False if unit == self._charm.unit.name: # Lock acquired # Release peer databag lock, if any