Skip to content

Commit

Permalink
Fix backup status on non-leader units (#298)
Browse files Browse the repository at this point in the history
## Issue:
The backup module sets application status on non-leader units, which
causes an exception as a non allowed operation.
  • Loading branch information
phvalguima authored May 6, 2024
1 parent c8e0446 commit a402510
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions lib/charms/opensearch/v0/opensearch_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,14 +294,16 @@ def _on_peer_relation_changed(self, event) -> None:

def _on_s3_relation_event(self, event: EventBase) -> None:
"""Processes the non-orchestrator cluster events."""
self.charm.status.set(BlockedStatus(S3RelShouldNotExist), app=True)
if self.charm.unit.is_leader():
self.charm.status.set(BlockedStatus(S3RelShouldNotExist), app=True)
logger.info("Non-orchestrator cluster, abandon s3 relation event")
return

def _on_s3_relation_broken(self, event: EventBase) -> None:
"""Processes the non-orchestrator cluster events."""
self.charm.status.clear(S3RelMissing)
self.charm.status.clear(S3RelShouldNotExist, app=True)
if self.charm.unit.is_leader():
self.charm.status.clear(S3RelShouldNotExist, app=True)
logger.info("Non-orchestrator cluster, abandon s3 relation event")
return

Expand Down Expand Up @@ -738,10 +740,12 @@ def apply_api_config_if_needed(self) -> None:
# (3) based on the response, set the message status
if state != BackupServiceState.SUCCESS:
logger.error(f"Failed to setup backup service with state {state}")
self.charm.status.set(BlockedStatus(BackupSetupFailed), app=True)
if self.charm.unit.is_leader():
self.charm.status.set(BlockedStatus(BackupSetupFailed), app=True)
self.charm.status.clear(BackupConfigureStart)
return
self.charm.status.clear(BackupSetupFailed, app=True)
if self.charm.unit.is_leader():
self.charm.status.clear(BackupSetupFailed, app=True)
self.charm.status.clear(BackupConfigureStart)

def _on_s3_created(self, _):
Expand Down

0 comments on commit a402510

Please sign in to comment.