hsato03 commented on code in PR #12086:
URL: https://github.com/apache/cloudstack/pull/12086#discussion_r3149059912
##########
engine/orchestration/src/main/java/org/apache/cloudstack/engine/orchestration/StorageOrchestrator.java:
##########
@@ -346,20 +370,102 @@ protected Map<Long, Pair<Long, Long>> migrateAway(
executor.setCorePoolSize((int) (totalJobs));
}
- MigrateDataTask task = new MigrateDataTask(chosenFileForMigration,
srcDatastore, dataStoreManager.getDataStore(destDatastoreId,
DataStoreRole.Image));
- if (chosenFileForMigration instanceof SnapshotInfo ) {
+ DataStore destDataStore =
dataStoreManager.getDataStore(destDatastoreId, DataStoreRole.Image);
+
+ boolean isKvmIncrementalSnapshot = chosenFileForMigration instanceof
SnapshotInfo && ((SnapshotInfo)
chosenFileForMigration).isKvmIncrementalSnapshot() &&
snapshotChains.containsKey(chosenFileForMigration);
+
+ if (isKvmIncrementalSnapshot) {
+ MigrateKvmIncrementalSnapshotTask task = new
MigrateKvmIncrementalSnapshotTask(chosenFileForMigration, snapshotChains,
srcDatastore, destDataStore, snapshotIdsToMigrate);
+
futures.add(submitKvmIncrementalMigration(srcDatastore.getScope().getScopeId(),
task));
+ logger.debug("Incremental snapshot migration {} submitted to
incremental pool.", chosenFileForMigration.getUuid());
+ } else {
+ createMigrateDataTask(chosenFileForMigration, snapshotChains,
templateChains, srcDatastore, destDataStore, executor, futures);
+ }
+
+ return storageCapacities;
+ }
+
+ private AsyncCallFuture<DataObjectResult>
migrateKvmIncrementalSnapshotChain(DataObject chosenFileForMigration,
Map<DataObject, Pair<List<SnapshotInfo>, Long>> snapshotChains, DataStore
srcDatastore, DataStore destDataStore, Set<Long> snapshotIdsToMigrate) {
+ return
Transaction.execute((TransactionCallback<AsyncCallFuture<DataObjectResult>>)
status -> {
+ MigrateBetweenSecondaryStoragesCommandAnswer answer = null;
+ AsyncCallFuture<DataObjectResult> future = new AsyncCallFuture<>();
+ DataObjectResult result = new
DataObjectResult(chosenFileForMigration);
+
+ try {
+ List<SnapshotInfo> snapshotChain =
snapshotChains.get(chosenFileForMigration).first();
+ MigrateSnapshotsBetweenSecondaryStoragesCommand
migrateBetweenSecondaryStoragesCmd = new
MigrateSnapshotsBetweenSecondaryStoragesCommand(snapshotChain.stream().map(DataObject::getTO).collect(Collectors.toList()),
srcDatastore.getTO(), destDataStore.getTO(), snapshotIdsToMigrate);
+
+ HostVO host = getAvailableHost(((SnapshotInfo)
chosenFileForMigration).getDataCenterId());
+ if (host == null) {
+ throw new CloudRuntimeException("No suitable hosts found
to send migrate command.");
+ }
+
+
migrateBetweenSecondaryStoragesCmd.setWait(StorageManager.AgentMaxDataMigrationWaitTime.valueIn(host.getClusterId()));
+ answer = (MigrateBetweenSecondaryStoragesCommandAnswer)
agentManager.send(host.getId(), migrateBetweenSecondaryStoragesCmd);
+ if (answer == null || !answer.getResult()) {
+ logger.warn("Unable to migrate snapshots [{}].",
snapshotChain);
+ throw new CloudRuntimeException("Unable to migrate KVM
incremental snapshots to another secondary storage");
+ }
+ } catch (final OperationTimedoutException |
AgentUnavailableException e) {
+ throw new CloudRuntimeException("Error while migrating KVM
incremental snapshot chain. Check the logs for more information.", e);
Review Comment:
Yes.
https://github.com/apache/cloudstack/pull/12086/changes#diff-3165894c0b4560ccad18e0e756b025d6ab17148f095cb4422e03092952b6d0d2R108
--
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]