Skip to content

Commit 2c11ede

Browse files
committed
Address Joao reviews
1 parent 036a51c commit 2c11ede

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/StorageOrchestrator.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -402,8 +402,10 @@ private void migrateKvmIncrementalSnapshotChain(DataObject chosenFileForMigratio
402402
migrateBetweenSecondaryStoragesCmd.setWait(StorageManager.AgentMaxDataMigrationWaitTime.valueIn(host.getClusterId()));
403403
answer = (MigrateBetweenSecondaryStoragesCommandAnswer) agentManager.send(host.getId(), migrateBetweenSecondaryStoragesCmd);
404404
if (answer == null || !answer.getResult()) {
405-
logger.warn("Unable to migrate snapshots [{}].", snapshotChain);
406-
throw new CloudRuntimeException("Unable to migrate KVM incremental snapshots to another secondary storage");
405+
if (answer != null) {
406+
logger.warn(answer.getDetails());
407+
}
408+
throw new CloudRuntimeException("Unable to migrate KVM incremental snapshots to another secondary storage.");
407409
}
408410
} catch (final OperationTimedoutException | AgentUnavailableException e) {
409411
throw new CloudRuntimeException("Error while migrating KVM incremental snapshot chain. Check the logs for more information.", e);
@@ -416,7 +418,6 @@ private void migrateKvmIncrementalSnapshotChain(DataObject chosenFileForMigratio
416418
});
417419
}
418420

419-
420421
private void updateSnapshotsReference(DataStore destDataStore, MigrateBetweenSecondaryStoragesCommandAnswer answer) {
421422
for (Pair<Long, String> snapshotIdAndUpdatedCheckpointPath : answer.getMigratedResources()) {
422423
Long snapshotId = snapshotIdAndUpdatedCheckpointPath.first();

plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtMigrateSnapshotsBetweenSecondaryStoragesCommandWrapper.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,29 +76,37 @@ public Answer execute(MigrateSnapshotsBetweenSecondaryStoragesCommand command, L
7676
boolean parentSnapshotWasMigrated = false;
7777
Set<Long> snapshotsIdToMigrate = command.getSnapshotsIdToMigrate();
7878

79+
DataTO currentSnapshot = null;
80+
7981
try {
8082
for (DataTO snapshot : command.getSnapshotChain()) {
83+
currentSnapshot = snapshot;
8184
imagePoolUrl = snapshot.getDataStore().getUrl();
8285
imagePool = storagePoolManager.getStoragePoolByURI(imagePoolUrl);
8386
imagePools.add(imagePool);
8487

8588
String resourceCurrentPath = imagePool.getLocalPathFor(snapshot.getPath());
8689

8790
if (imagePoolUrl.equals(srcDataStore.getUrl()) && snapshotsIdToMigrate.contains(snapshot.getId())) {
91+
logger.debug("Migrating snapshot [{}] to destination storage pool [{}].", snapshot.getId(), destImagePool.getUuid());
8892
parentSnapshotPath = copyResourceToDestDataStore(snapshot, resourceCurrentPath, destImagePool, parentSnapshotPath);
8993
parentSnapshotWasMigrated = true;
94+
logger.debug("Snapshot [{}] migrated successfully. New parent path: [{}]", snapshot.getId(), parentSnapshotPath);
9095
} else {
9196
if (parentSnapshotWasMigrated) {
97+
logger.debug("Rebasing snapshot [{}] to new parent path: [{}]", snapshot.getId(), parentSnapshotPath);
9298
parentSnapshotPath = rebaseResourceToNewParentPath(resourceCurrentPath, parentSnapshotPath);
9399
} else {
100+
logger.debug("Skipping migration/rebase for snapshot [{}]. Keeping current path.", snapshot.getId());
94101
parentSnapshotPath = resourceCurrentPath;
95102
}
96103
parentSnapshotWasMigrated = false;
97104
}
98105
}
106+
logger.info("Successfully completed migrating snapshot chain [{}].", command.getSnapshotChain());
99107
} catch (LibvirtException | QemuImgException e) {
100108
logger.error("Exception while migrating snapshots [{}] to secondary storage [{}] due to: [{}].", command.getSnapshotChain(), imagePool, e.getMessage(), e);
101-
return new MigrateBetweenSecondaryStoragesCommandAnswer(command, false, "Migration of snapshots between secondary storages failed", resourcesToUpdate);
109+
return new MigrateBetweenSecondaryStoragesCommandAnswer(command, false, String.format("Unable to migrate snapshot with ID [%s].", currentSnapshot.getId()), resourcesToUpdate);
102110
} finally {
103111
for (String file : filesToRemove) {
104112
removeResourceFromSourceDataStore(file);

0 commit comments

Comments
 (0)