diff --git a/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java b/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java index cf6c1541ff96..c04538271a1d 100644 --- a/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java +++ b/plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java @@ -638,7 +638,10 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal //check if snapshot is on secondary storage StorPoolUtil.spLog("Snapshot %s does not exists on StorPool, will try to create a volume from a snapshot on secondary storage", snapshotName); SnapshotDataStoreVO snap = getSnapshotImageStoreRef(sinfo.getId(), vinfo.getDataCenterId()); - if (snap != null && StorPoolStorageAdaptor.getVolumeNameFromPath(snap.getInstallPath(), false) == null) { + SnapshotDetailsVO snapshotDetail = snapshotDetailsDao.findDetail(sinfo.getId(), StorPoolUtil.SP_DELAY_DELETE); + if (snapshotDetail != null) { + err = String.format("Could not create volume from snapshot due to: %s. The snapshot was created with the delayDelete option.", resp.getError()); + } else if (snap != null && StorPoolStorageAdaptor.getVolumeNameFromPath(snap.getInstallPath(), false) == null) { SpApiResponse emptyVolumeCreateResp = StorPoolUtil.volumeCreate(volumeName, null, size, null, null, "volume", null, conn); if (emptyVolumeCreateResp.getError() == null) { answer = createVolumeFromSnapshot(srcData, dstData, size, emptyVolumeCreateResp); @@ -974,12 +977,12 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal private Answer createVolumeSnapshot(StorageSubSystemCommand cmd, Long size, SpConnectionDesc conn, String volName, TemplateObjectTO dstTO) { Answer answer; - SpApiResponse resp2 = StorPoolUtil.volumeSnapshot(volName, dstTO.getUuid(), null, "template", null, conn); - if (resp2.getError() != null) { - answer = new Answer(cmd, false, String.format("Could not snapshot volume. Error: %s", resp2.getError())); + SpApiResponse resp = StorPoolUtil.volumeSnapshot(volName, dstTO.getUuid(), null, "template", null, conn); + if (resp.getError() != null) { + answer = new Answer(cmd, false, String.format("Could not snapshot volume. Error: %s", resp.getError())); } else { dstTO.setPath(StorPoolUtil.devPath( - StorPoolUtil.getSnapshotNameFromResponse(resp2, false, StorPoolUtil.GLOBAL_ID))); + StorPoolUtil.getSnapshotNameFromResponse(resp, false, StorPoolUtil.GLOBAL_ID))); dstTO.setSize(size); answer = new CopyCmdAnswer(dstTO); } @@ -993,16 +996,16 @@ private Answer createVolumeFromSnapshot(DataObject srcData, DataObject dstData, VolumeObjectTO dstTO = (VolumeObjectTO) dstData.getTO(); dstTO.setSize(size); dstTO.setPath(StorPoolUtil.devPath(name)); - StorageSubSystemCommand cmd1 = new StorPoolDownloadTemplateCommand(srcData.getTO(), dstTO, StorPoolHelper.getTimeout(StorPoolHelper.PrimaryStorageDownloadWait, configDao), VirtualMachineManager.ExecuteInSequence.value(), "volume"); + StorageSubSystemCommand cmd = new StorPoolDownloadTemplateCommand(srcData.getTO(), dstTO, StorPoolHelper.getTimeout(StorPoolHelper.PrimaryStorageDownloadWait, configDao), VirtualMachineManager.ExecuteInSequence.value(), "volume"); EndPoint ep = selector.select(srcData, dstData); if (ep == null) { - answer = new Answer(cmd1, false, "\"No remote endpoint to send command, check if host or ssvm is down?\""); + answer = new Answer(cmd, false, "\"No remote endpoint to send command, check if host or ssvm is down?\""); } else { - answer = ep.sendMessage(cmd1); + answer = ep.sendMessage(cmd); } if (answer == null || !answer.getResult()) { - answer = new Answer(cmd1, false, answer != null ? answer.getDetails() : "Unknown error while downloading template. Null answer returned."); + answer = new Answer(cmd, false, answer != null ? answer.getDetails() : "Unknown error while downloading template. Null answer returned."); } return answer; }