Skip to content
Merged
Show file tree
Hide file tree
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
5 changes: 4 additions & 1 deletion src/backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,10 @@ def can_use_s3_repository(self) -> tuple[bool, str | None]:
for line in system_identifier_from_instance.splitlines()
if "Database system identifier" in line
).split(" ")[-1]
system_identifier_from_stanza = str(stanza.get("db")[0]["system-id"])
stanza_dbs = stanza.get("db")
system_identifier_from_stanza = (
str(stanza_dbs[0]["system-id"]) if len(stanza_dbs) else None
)
if system_identifier_from_instance != system_identifier_from_stanza:
logger.debug(
f"can_use_s3_repository: incompatible system identifier s3={system_identifier_from_stanza}, local={system_identifier_from_instance}"
Expand Down
12 changes: 12 additions & 0 deletions tests/unit/test_backups.py
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,18 @@ def test_can_use_s3_repository(harness):
]
assert harness.charm.backup.can_use_s3_repository() == (True, None)

# Empty db
_execute_command.side_effect = [
(
f'[{{"db": [], "name": "another-model.{harness.charm.cluster_name}"}}]',
None,
)
]
assert harness.charm.backup.can_use_s3_repository() == (
False,
ANOTHER_CLUSTER_REPOSITORY_ERROR_MESSAGE,
)


def test_construct_endpoint(harness):
# Test with an AWS endpoint without region.
Expand Down
Loading