Skip to content
Open
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
9 changes: 4 additions & 5 deletions simplyblock_core/controllers/backup_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def restore_backup(backup_id: str, lvol_name: str, pool_id_or_name: str, cluster
from simplyblock_core.models.lvol_model import LVol

try:
backup = db_controller.get_backup_by_id(backup_id)
backup = db_controller.get_backup_by_id(backup_id, cluster_id)
cluster = db_controller.get_cluster_by_id(cluster_id)
except KeyError as e:
return None, str(e)
Expand All @@ -428,7 +428,7 @@ def restore_backup(backup_id: str, lvol_name: str, pool_id_or_name: str, cluster
f"{backup_src}' first.")

# Build the backup chain
chain = db_controller.get_backup_chain(backup_id)
chain = db_controller.get_backup_chain(backup_id, cluster_id)
if not chain:
return None, f"Could not build backup chain for {backup_id}"

Expand Down Expand Up @@ -655,9 +655,8 @@ def import_backups(s3_metadata_list, cluster_id=None):

# Skip only if already registered for the target cluster
try:
existing = db_controller.get_backup_by_id(backup_id)
if existing.cluster_id == target_cluster:
continue # already imported for this cluster
db_controller.get_backup_by_id(backup_id, target_cluster)
continue # already imported for this cluster
except KeyError:
pass

Expand Down
9 changes: 5 additions & 4 deletions simplyblock_core/db_controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1357,8 +1357,9 @@ def get_backups(self, cluster_id: Optional[str] = None) -> List[Backup]:
prefix = cluster_id if cluster_id else " "
return Backup().read_from_db(self.kv_store, id=prefix)

def get_backup_by_id(self, backup_id: str) -> Backup:
backup = single_or_none(b for b in self.get_backups() if b.uuid == backup_id)
def get_backup_by_id(self, backup_id: str, cluster_id: Optional[str] = None) -> Backup:
backup = single_or_none(
b for b in self.get_backups(cluster_id) if b.uuid == backup_id)
if backup is None:
raise KeyError(f'Backup {backup_id} not found')
return backup
Expand All @@ -1369,15 +1370,15 @@ def get_backups_by_lvol_id(self, lvol_id: str) -> List[Backup]:
def get_backups_by_snapshot_id(self, snapshot_id: str) -> List[Backup]:
return [b for b in self.get_backups() if b.snapshot_id == snapshot_id]

def get_backup_chain(self, backup_id: str) -> List[Backup]:
def get_backup_chain(self, backup_id: str, cluster_id: Optional[str] = None) -> List[Backup]:
"""Return the full backup chain ending at backup_id, oldest first."""
chain = []
current_id = backup_id
visited = set()
while current_id and current_id not in visited:
visited.add(current_id)
try:
backup = self.get_backup_by_id(current_id)
backup = self.get_backup_by_id(current_id, cluster_id)
except KeyError:
break
chain.append(backup)
Expand Down
2 changes: 1 addition & 1 deletion simplyblock_core/env_var
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
SIMPLY_BLOCK_COMMAND_NAME=sbcli-dev
SIMPLY_BLOCK_VERSION=19.2.34

SIMPLY_BLOCK_DOCKER_IMAGE=public.ecr.aws/simply-block/simplyblock:main
SIMPLY_BLOCK_DOCKER_IMAGE=public.ecr.aws/simply-block/simplyblock:fix-backup-get-by-id-cluster-filter
SIMPLY_BLOCK_SPDK_ULTRA_IMAGE=public.ecr.aws/simply-block/ultra:main-latest
Loading