hsato03 commented on code in PR #12086:
URL: https://github.com/apache/cloudstack/pull/12086#discussion_r3149035875
##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/DataMigrationUtility.java:
##########
@@ -297,16 +311,30 @@ protected List<DataObject>
getAllReadySnapshotsAndChains(DataStore srcDataStore,
logger.debug("Not migrating snapshot [{}] because its
hypervisor type is simulator.", snapshot);
continue;
}
- if (snapshot.getParentSnapshotId() != 0) {
+ boolean isKvmIncrementalSnapshot = snapshot.getKvmCheckpointPath()
!= null;
+ if (snapshot.getParentSnapshotId() != 0 &&
!isKvmIncrementalSnapshot) {
continue; // The child snapshot will be migrated in the for
loop below.
}
- SnapshotInfo snap =
snapshotFactory.getSnapshot(snapshotVO.getSnapshotId(),
snapshot.getDataStoreId(), snapshot.getRole());
- if (snap == null) {
- logger.debug("Not migrating snapshot [{}] because we could not
get its information.", snapshot);
+ if (snapshotIdsAlreadyInChain.contains(snapshotVO.getId())) {
+ logger.debug("Skipping snapshot {} since it is already in
snapshot chain.", snapshot);
continue;
}
- files.add(snap);
- idsForMigration.add(snapshotId);
+
+ if (isKvmIncrementalSnapshot) {
+ List<SnapshotInfo> kvmIncrementalSnapshotChain =
createKvmIncrementalSnapshotChain(snapshot);
+ SnapshotInfo parent = kvmIncrementalSnapshotChain.get(0);
+
snapshotIdsAlreadyInChain.addAll(kvmIncrementalSnapshotChain.stream().map(DataObject::getId).collect(Collectors.toSet()));
+ snapshotChains.put(parent, new
Pair<>(kvmIncrementalSnapshotChain,
getTotalChainSize(kvmIncrementalSnapshotChain.stream().filter(snapInfo ->
snapshotIdsToMigrate.contains(snapInfo.getId())).collect(Collectors.toList()))));
+ files.add(parent);
+ } else {
Review Comment:
Since the snapshot chain is created with a single iteration, and multiple
snapshots from the same chain can go through this `for` loop, I thought this
way would be more organized.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]