Skip to content

Commit

Permalink
addressed comments
Browse files Browse the repository at this point in the history
  • Loading branch information
slavkap committed Jan 9, 2025
1 parent e539045 commit 3d31305
Showing 1 changed file with 12 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Check warning on line 643 in plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L643 was not covered by tests
} else if (snap != null && StorPoolStorageAdaptor.getVolumeNameFromPath(snap.getInstallPath(), false) == null) {
SpApiResponse emptyVolumeCreateResp = StorPoolUtil.volumeCreate(volumeName, null, size, null, null, "volume", null, conn);

Check warning on line 645 in plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L645 was not covered by tests
if (emptyVolumeCreateResp.getError() == null) {
answer = createVolumeFromSnapshot(srcData, dstData, size, emptyVolumeCreateResp);

Check warning on line 647 in plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L647 was not covered by tests
Expand Down Expand Up @@ -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);

Check warning on line 980 in plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

View check run for this annotation

Codecov / codecov/patch

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java#L978-L980

Added lines #L978 - L980 were not covered by tests
if (resp.getError() != null) {
answer = new Answer(cmd, false, String.format("Could not snapshot volume. Error: %s", resp.getError()));

Check warning on line 982 in plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L982 was not covered by tests
} 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);

Check warning on line 987 in plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

View check run for this annotation

Codecov / codecov/patch

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java#L984-L987

Added lines #L984 - L987 were not covered by tests
}
Expand All @@ -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");

Check warning on line 999 in plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

View check run for this annotation

Codecov / codecov/patch

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java#L993-L999

Added lines #L993 - L999 were not covered by tests

EndPoint ep = selector.select(srcData, dstData);

Check warning on line 1001 in plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1001 was not covered by tests
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?\"");

Check warning on line 1003 in plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1003 was not covered by tests
} else {
answer = ep.sendMessage(cmd1);
answer = ep.sendMessage(cmd);

Check warning on line 1005 in plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

View check run for this annotation

Codecov / codecov/patch

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

Added line #L1005 was not covered by tests
}
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;
}

Check warning on line 1011 in plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java

View check run for this annotation

Codecov / codecov/patch

plugins/storage/volume/storpool/src/main/java/org/apache/cloudstack/storage/datastore/driver/StorPoolPrimaryDataStoreDriver.java#L1010-L1011

Added lines #L1010 - L1011 were not covered by tests
Expand Down

0 comments on commit 3d31305

Please sign in to comment.