Skip to content

Commit

Permalink
feat(backup): Go to blocked if invalid integration (#345)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gu1nness authored Oct 11, 2024
1 parent 134c10c commit f0a7578
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/charms/mongodb/v1/mongodb_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@

# Increment this PATCH version before using `charmcraft publish-lib` or reset
# to 0 if you are raising the major API version
LIBPATCH = 4
LIBPATCH = 5

logger = logging.getLogger(__name__)

Expand All @@ -61,6 +61,10 @@
BACKUP_RESTORE_MAX_ATTEMPTS = 10
BACKUP_RESTORE_ATTEMPT_COOLDOWN = 15

INVALID_INTEGRATION_STATUS = BlockedStatus(
"Relation to s3-integrator is not supported, config role must be config-server"
)


_StrOrBytes = Union[str, bytes]

Expand Down Expand Up @@ -136,11 +140,7 @@ def on_s3_relation_joined(self, event: RelationJoinedEvent) -> None:
logger.debug(
"Shard does not support s3 relations, please relate s3-integrator to config-server only."
)
self.charm.status.set_and_share_status(
BlockedStatus(
"Relation to s3-integrator is not supported, config role must be config-server"
)
)
self.charm.status.set_and_share_status(INVALID_INTEGRATION_STATUS)

def _on_s3_credential_changed(self, event: CredentialsChangedEvent):
"""Sets pbm credentials, resyncs if necessary and reports config errors."""
Expand All @@ -154,7 +154,11 @@ def _on_s3_credential_changed(self, event: CredentialsChangedEvent):
event.defer()
return

if not self._pass_sanity_checks(event, action):
if not self.is_valid_s3_integration():
logger.debug(
"Shard does not support s3 relations, please relate s3-integrator to config-server only."
)
self.charm.status.set_and_share_status(INVALID_INTEGRATION_STATUS)
return

if not self.charm.db_initialised:
Expand Down

0 comments on commit f0a7578

Please sign in to comment.