Skip to content

Commit 0e78ba9

Browse files
committed
addressed comments
1 parent 7138626 commit 0e78ba9

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
@@ -638,7 +638,10 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal
638638
//check if snapshot is on secondary storage
639639
StorPoolUtil.spLog("Snapshot %s does not exists on StorPool, will try to create a volume from a snapshot on secondary storage", snapshotName);
640640
SnapshotDataStoreVO snap = getSnapshotImageStoreRef(sinfo.getId(), vinfo.getDataCenterId());
641-
if (snap != null && StorPoolStorageAdaptor.getVolumeNameFromPath(snap.getInstallPath(), false) == null) {
641+
SnapshotDetailsVO snapshotDetail = snapshotDetailsDao.findDetail(sinfo.getId(), StorPoolUtil.SP_DELAY_DELETE);
642+
if (snapshotDetail != null) {
643+
err = String.format("Could not create volume from snapshot due to: %s. The snapshot was created with the delayDelete option.", resp.getError());
644+
} else if (snap != null && StorPoolStorageAdaptor.getVolumeNameFromPath(snap.getInstallPath(), false) == null) {
642645
SpApiResponse emptyVolumeCreateResp = StorPoolUtil.volumeCreate(volumeName, null, size, null, null, "volume", null, conn);
643646
if (emptyVolumeCreateResp.getError() == null) {
644647
answer = createVolumeFromSnapshot(srcData, dstData, size, emptyVolumeCreateResp);
@@ -974,12 +977,12 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal
974977
private Answer createVolumeSnapshot(StorageSubSystemCommand cmd, Long size, SpConnectionDesc conn,
975978
String volName, TemplateObjectTO dstTO) {
976979
Answer answer;
977-
SpApiResponse resp2 = StorPoolUtil.volumeSnapshot(volName, dstTO.getUuid(), null, "template", null, conn);
978-
if (resp2.getError() != null) {
979-
answer = new Answer(cmd, false, String.format("Could not snapshot volume. Error: %s", resp2.getError()));
980+
SpApiResponse resp = StorPoolUtil.volumeSnapshot(volName, dstTO.getUuid(), null, "template", null, conn);
981+
if (resp.getError() != null) {
982+
answer = new Answer(cmd, false, String.format("Could not snapshot volume. Error: %s", resp.getError()));
980983
} else {
981984
dstTO.setPath(StorPoolUtil.devPath(
982-
StorPoolUtil.getSnapshotNameFromResponse(resp2, false, StorPoolUtil.GLOBAL_ID)));
985+
StorPoolUtil.getSnapshotNameFromResponse(resp, false, StorPoolUtil.GLOBAL_ID)));
983986
dstTO.setSize(size);
984987
answer = new CopyCmdAnswer(dstTO);
985988
}
@@ -993,16 +996,16 @@ private Answer createVolumeFromSnapshot(DataObject srcData, DataObject dstData,
993996
VolumeObjectTO dstTO = (VolumeObjectTO) dstData.getTO();
994997
dstTO.setSize(size);
995998
dstTO.setPath(StorPoolUtil.devPath(name));
996-
StorageSubSystemCommand cmd1 = new StorPoolDownloadTemplateCommand(srcData.getTO(), dstTO, StorPoolHelper.getTimeout(StorPoolHelper.PrimaryStorageDownloadWait, configDao), VirtualMachineManager.ExecuteInSequence.value(), "volume");
999+
StorageSubSystemCommand cmd = new StorPoolDownloadTemplateCommand(srcData.getTO(), dstTO, StorPoolHelper.getTimeout(StorPoolHelper.PrimaryStorageDownloadWait, configDao), VirtualMachineManager.ExecuteInSequence.value(), "volume");
9971000

9981001
EndPoint ep = selector.select(srcData, dstData);
9991002
if (ep == null) {
1000-
answer = new Answer(cmd1, false, "\"No remote endpoint to send command, check if host or ssvm is down?\"");
1003+
answer = new Answer(cmd, false, "\"No remote endpoint to send command, check if host or ssvm is down?\"");
10011004
} else {
1002-
answer = ep.sendMessage(cmd1);
1005+
answer = ep.sendMessage(cmd);
10031006
}
10041007
if (answer == null || !answer.getResult()) {
1005-
answer = new Answer(cmd1, false, answer != null ? answer.getDetails() : "Unknown error while downloading template. Null answer returned.");
1008+
answer = new Answer(cmd, false, answer != null ? answer.getDetails() : "Unknown error while downloading template. Null answer returned.");
10061009
}
10071010
return answer;
10081011
}

0 commit comments

Comments
 (0)