Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(backup): Go to blocked if invalid integration #345

Merged
merged 1 commit into from
Oct 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading