Skip to content

Commit d099649

Browse files
committed
addressed comments
1 parent 02a98f0 commit d099649

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,10 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal
550550
//check if snapshot is on secondary storage
551551
StorPoolUtil.spLog("Snapshot %s does not exists on StorPool, will try to create a volume from a snapshot on secondary storage", snapshotName);
552552
SnapshotDataStoreVO snap = getSnapshotImageStoreRef(sinfo.getId(), vinfo.getDataCenterId());
553-
if (snap != null && StorPoolStorageAdaptor.getVolumeNameFromPath(snap.getInstallPath(), false) == null) {
553+
SnapshotDetailsVO snapshotDetail = snapshotDetailsDao.findDetail(sinfo.getId(), StorPoolUtil.SP_DELAY_DELETE);
554+
if (snapshotDetail != null) {
555+
err = String.format("Could not create volume from snapshot due to: %s. The snapshot was created with the delayDelete option.", resp.getError());
556+
} else if (snap != null && StorPoolStorageAdaptor.getVolumeNameFromPath(snap.getInstallPath(), false) == null) {
554557
SpApiResponse emptyVolumeCreateResp = StorPoolUtil.volumeCreate(volumeName, null, size, null, null, "volume", null, conn);
555558
if (emptyVolumeCreateResp.getError() == null) {
556559
answer = createVolumeFromSnapshot(srcData, dstData, size, emptyVolumeCreateResp);
@@ -864,12 +867,12 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal
864867
private Answer createVolumeSnapshot(StorageSubSystemCommand cmd, Long size, SpConnectionDesc conn,
865868
String volName, TemplateObjectTO dstTO) {
866869
Answer answer;
867-
SpApiResponse resp2 = StorPoolUtil.volumeSnapshot(volName, dstTO.getUuid(), null, "template", null, conn);
868-
if (resp2.getError() != null) {
869-
answer = new Answer(cmd, false, String.format("Could not snapshot volume. Error: %s", resp2.getError()));
870+
SpApiResponse resp = StorPoolUtil.volumeSnapshot(volName, dstTO.getUuid(), null, "template", null, conn);
871+
if (resp.getError() != null) {
872+
answer = new Answer(cmd, false, String.format("Could not snapshot volume. Error: %s", resp.getError()));
870873
} else {
871874
dstTO.setPath(StorPoolUtil.devPath(
872-
StorPoolUtil.getSnapshotNameFromResponse(resp2, false, StorPoolUtil.GLOBAL_ID)));
875+
StorPoolUtil.getSnapshotNameFromResponse(resp, false, StorPoolUtil.GLOBAL_ID)));
873876
dstTO.setSize(size);
874877
answer = new CopyCmdAnswer(dstTO);
875878
}
@@ -883,16 +886,16 @@ private Answer createVolumeFromSnapshot(DataObject srcData, DataObject dstData,
883886
VolumeObjectTO dstTO = (VolumeObjectTO) dstData.getTO();
884887
dstTO.setSize(size);
885888
dstTO.setPath(StorPoolUtil.devPath(name));
886-
StorageSubSystemCommand cmd1 = new StorPoolDownloadTemplateCommand(srcData.getTO(), dstTO, StorPoolHelper.getTimeout(StorPoolHelper.PrimaryStorageDownloadWait, configDao), VirtualMachineManager.ExecuteInSequence.value(), "volume");
889+
StorageSubSystemCommand cmd = new StorPoolDownloadTemplateCommand(srcData.getTO(), dstTO, StorPoolHelper.getTimeout(StorPoolHelper.PrimaryStorageDownloadWait, configDao), VirtualMachineManager.ExecuteInSequence.value(), "volume");
887890

888891
EndPoint ep = selector.select(srcData, dstData);
889892
if (ep == null) {
890-
answer = new Answer(cmd1, false, "\"No remote endpoint to send command, check if host or ssvm is down?\"");
893+
answer = new Answer(cmd, false, "\"No remote endpoint to send command, check if host or ssvm is down?\"");
891894
} else {
892-
answer = ep.sendMessage(cmd1);
895+
answer = ep.sendMessage(cmd);
893896
}
894897
if (answer == null || !answer.getResult()) {
895-
answer = new Answer(cmd1, false, answer != null ? answer.getDetails() : "Unknown error while downloading template. Null answer returned.");
898+
answer = new Answer(cmd, false, answer != null ? answer.getDetails() : "Unknown error while downloading template. Null answer returned.");
896899
}
897900
return answer;
898901
}

0 commit comments

Comments
 (0)