slavkap commented on code in PR #9478:
URL: https://github.com/apache/cloudstack/pull/9478#discussion_r1761277866
##########
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java:
##########
@@ -1502,9 +1546,59 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume)
throws ResourceAllocationExc
return snapshot;
}
- protected void backupSnapshotToSecondary(boolean asyncBackup,
SnapshotStrategy snapshotStrategy, SnapshotInfo snapshotOnPrimary, List<Long>
zoneIds) {
+ private void copyNewSnapshotToZonesOnPrimary(CreateSnapshotPayload
payload, SnapshotInfo snapshot) {
+ SnapshotStrategy snapshotStrategy;
+ snapshotStrategy =
_storageStrategyFactory.getSnapshotStrategy(snapshot, SnapshotOperation.COPY);
+ if (snapshotStrategy != null) {
+ for (Long storagePoolId : payload.getStoragePoolIds()) {
+ copySnapshotOnPool(snapshot, snapshotStrategy, storagePoolId);
+ }
+ } else {
+ logger.info("Unable to find snapshot strategy to handle the copy
of a snapshot with id " + snapshot.getUuid());
+ }
+ }
+
+ private boolean copySnapshotOnPool(SnapshotInfo snapshot, SnapshotStrategy
snapshotStrategy, Long storagePoolId) {
+ DataStore store = dataStoreMgr.getDataStore(storagePoolId,
DataStoreRole.Primary);
+ SnapshotInfo snapshotOnStore = (SnapshotInfo) store.create(snapshot);
+// if (snapshotOnStore.getStatus() ==
ObjectInDataStoreStateMachine.State.Allocated) {
+// snapshotOnStore.processEvent(Event.CreateOnlyRequested);
+// } else if (snapshotOnStore.getStatus() ==
ObjectInDataStoreStateMachine.State.Ready) {
+// snapshotOnStore.processEvent(Event.CopyRequested);
+// } else {
+// logger.info(String.format("Cannot copy snapshot to another
storage in different zone. It's not in the right state %s",
snapshotOnStore.getStatus()));
+// return false;
+// }
+
Review Comment:
thanks, it's removed in the latest commits
##########
server/src/main/java/com/cloud/storage/snapshot/SnapshotManagerImpl.java:
##########
@@ -1502,9 +1546,59 @@ public SnapshotInfo takeSnapshot(VolumeInfo volume)
throws ResourceAllocationExc
return snapshot;
}
- protected void backupSnapshotToSecondary(boolean asyncBackup,
SnapshotStrategy snapshotStrategy, SnapshotInfo snapshotOnPrimary, List<Long>
zoneIds) {
+ private void copyNewSnapshotToZonesOnPrimary(CreateSnapshotPayload
payload, SnapshotInfo snapshot) {
+ SnapshotStrategy snapshotStrategy;
+ snapshotStrategy =
_storageStrategyFactory.getSnapshotStrategy(snapshot, SnapshotOperation.COPY);
+ if (snapshotStrategy != null) {
+ for (Long storagePoolId : payload.getStoragePoolIds()) {
+ copySnapshotOnPool(snapshot, snapshotStrategy, storagePoolId);
+ }
+ } else {
+ logger.info("Unable to find snapshot strategy to handle the copy
of a snapshot with id " + snapshot.getUuid());
+ }
+ }
+
+ private boolean copySnapshotOnPool(SnapshotInfo snapshot, SnapshotStrategy
snapshotStrategy, Long storagePoolId) {
+ DataStore store = dataStoreMgr.getDataStore(storagePoolId,
DataStoreRole.Primary);
+ SnapshotInfo snapshotOnStore = (SnapshotInfo) store.create(snapshot);
+// if (snapshotOnStore.getStatus() ==
ObjectInDataStoreStateMachine.State.Allocated) {
+// snapshotOnStore.processEvent(Event.CreateOnlyRequested);
+// } else if (snapshotOnStore.getStatus() ==
ObjectInDataStoreStateMachine.State.Ready) {
+// snapshotOnStore.processEvent(Event.CopyRequested);
+// } else {
+// logger.info(String.format("Cannot copy snapshot to another
storage in different zone. It's not in the right state %s",
snapshotOnStore.getStatus()));
+// return false;
+// }
+
+ try {
+ AsyncCallFuture<SnapshotResult> future =
snapshotSrv.copySnapshot(snapshot, snapshotOnStore, snapshotStrategy);
+ SnapshotResult result = future.get();
+ if (result.isFailed()) {
+ logger.debug(String.format("Copy snapshot ID: %d failed for
primary storage %s: %s", snapshot.getSnapshotId(), storagePoolId,
result.getResult()));
+ return false;
+ }
+ snapshotZoneDao.addSnapshotToZone(snapshot.getId(),
snapshotOnStore.getDataCenterId());
+
_resourceLimitMgr.incrementResourceCount(CallContext.current().getCallingUserId(),
ResourceType.primary_storage, snapshot.getSize());
+ if (CallContext.current().getCallingUserId() !=
Account.ACCOUNT_ID_SYSTEM) {
+ SnapshotVO snapshotVO =
_snapshotDao.findByIdIncludingRemoved(snapshot.getSnapshotId());
+
UsageEventUtils.publishUsageEvent(EventTypes.EVENT_SNAPSHOT_COPY,
CallContext.current().getCallingUserId(), snapshotOnStore.getDataCenterId(),
snapshotVO.getId(), null, null, null, snapshotVO.getSize(),
+ snapshotVO.getSize(), snapshotVO.getClass().getName(),
snapshotVO.getUuid());
+ }
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ } catch (ExecutionException e) {
+ throw new RuntimeException(e);
+ }
+// boolean copySuccessful = snapshotStrategy.copySnapshot(snapshot,
snapshotOnStore, null);
+// if (!copySuccessful) {
+// snapshotOnStore.processEvent(Event.OperationFailed);
+// }
Review Comment:
removed in the latest commit
--
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]