diff --git a/lib/charms/opensearch/v0/opensearch_base_charm.py b/lib/charms/opensearch/v0/opensearch_base_charm.py index 56081f80d..c2697e87e 100644 --- a/lib/charms/opensearch/v0/opensearch_base_charm.py +++ b/lib/charms/opensearch/v0/opensearch_base_charm.py @@ -810,6 +810,10 @@ def _handle_change_to_main_orchestrator_if_needed( def _start_opensearch(self, event: _StartOpenSearch) -> None: # noqa: C901 """Start OpenSearch, with a generated or passed conf, if all resources configured.""" + if not self._can_service_start(): + self.node_lock.release() + event.defer() + return if not self.node_lock.acquired: # (Attempt to acquire lock even if `event.ignore_lock`) if event.ignore_lock: @@ -827,11 +831,6 @@ def _start_opensearch(self, event: _StartOpenSearch) -> None: # noqa: C901 event.defer() return - if not self._can_service_start(): - self.node_lock.release() - event.defer() - return - if self.opensearch.is_failed(): self.node_lock.release() self.status.set(BlockedStatus(ServiceStartError))