Skip to content

Commit f0a7578

Browse files
authored
feat(backup): Go to blocked if invalid integration (#345)
1 parent 134c10c commit f0a7578

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/charms/mongodb/v1/mongodb_backups.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141

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

4646
logger = logging.getLogger(__name__)
4747

@@ -61,6 +61,10 @@
6161
BACKUP_RESTORE_MAX_ATTEMPTS = 10
6262
BACKUP_RESTORE_ATTEMPT_COOLDOWN = 15
6363

64+
INVALID_INTEGRATION_STATUS = BlockedStatus(
65+
"Relation to s3-integrator is not supported, config role must be config-server"
66+
)
67+
6468

6569
_StrOrBytes = Union[str, bytes]
6670

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

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

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

160164
if not self.charm.db_initialised:

0 commit comments

Comments
 (0)