Skip to content

Commit

Permalink
Check if _can_service_start before acquiring lock
Browse files Browse the repository at this point in the history
  • Loading branch information
carlcsaposs-canonical committed May 2, 2024
1 parent 209e576 commit 3012f35
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions lib/charms/opensearch/v0/opensearch_base_charm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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))
Expand Down

0 comments on commit 3012f35

Please sign in to comment.