Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ private BackupVO createBackupObject(VirtualMachine vm, String backupPath) {
public boolean restoreVMFromBackup(VirtualMachine vm, Backup backup) {
List<Backup.VolumeInfo> backedVolumes = backup.getBackedUpVolumes();
List<VolumeVO> volumes = backedVolumes.stream()
.map(volume -> volumeDao.findByUuid(volume.getUuid()))
.map(volume -> volumeDao.findByUuid(volume.getPath()))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the new uuid or path after migration needs to be updated in the backed-up volumes metadata if any backups existing for them? any case path might also change?

Copy link
Contributor Author

@Pearl1594 Pearl1594 Jan 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new UUID / path for the backed up volume doesn't need to be updated as the uuid - points to the volume UUID - which is always the same on subsequent backups, and the path points to the backup path - which shouldn't vary even if volume is migrated. I don't see the path of the backup changing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
.map(volume -> volumeDao.findByUuid(volume.getPath()))
.map(backedVolumeInfo -> volumeDao.findByUuid(backedVolumeInfo.getPath()))

it's better change to backedVolumeInfo to avoid confusion.

@Pearl1594 Correct, path of the backup doesn't change. I mean, the volume path after migration might change as the volume is checked by its backed up path (which is before migration). cc @abh1sar

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

volumeDao.findByUuid() should take volume.getUuid() as an argument not path.

Volume paths are actually set in restoreCommand.setVolumePaths(getVolumePaths(volumes));
which is getting the path from volume.getPath().
So, ideally it should work as is. Can you check?

The bug is obvious in Restore single volume code restoreCommand.setVolumePaths(Collections.singletonList(String.format("%s/%s", dataStore.getLocalPath(), volumeUUID)));
-- here we should use the volume path not uuid

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my bad - I did the test / changes and 4.22 but made the wrong change on 4.20 - I meant to change this: to getPath from getUUID() - https://github.com/apache/cloudstack/blob/4.22/plugins/backup/nas/src/main/java/org/apache/cloudstack/backup/NASBackupProvider.java#L295
I'll fix it.

.sorted((v1, v2) -> Long.compare(v1.getDeviceId(), v2.getDeviceId()))
.collect(Collectors.toList());

Expand Down