Skip to content

Commit 425d257

Browse files
committed
linstor: improve aborting copyAsync
Seems instead of returning a unsuccessful answer it is better to throw a CloudRuntimeException for error handling.
1 parent d26122b commit 425d257

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

plugins/storage/volume/linstor/src/main/java/org/apache/cloudstack/storage/datastore/driver/LinstorPrimaryDataStoreDriverImpl.java

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1063,9 +1063,7 @@ public void copyAsync(DataObject srcData, DataObject dstData, AsyncCompletionCal
10631063
Answer answer = copyVolume(srcData, dstData);
10641064
res = new CopyCommandResult(null, answer);
10651065
} else {
1066-
Answer answer = new Answer(null, false, "noimpl");
1067-
res = new CopyCommandResult(null, answer);
1068-
res.setResult("Not implemented yet");
1066+
throw new CloudRuntimeException("Not implemented for Linstor primary storage.");
10691067
}
10701068
callback.complete(res);
10711069
}
@@ -1203,8 +1201,8 @@ private Answer copyTemplate(DataObject srcData, DataObject dstData) {
12031201
if (optEP.isPresent()) {
12041202
answer = optEP.get().sendMessage(cmd);
12051203
} else {
1206-
answer = new Answer(cmd, false, "Unable to get matching Linstor endpoint.");
12071204
deleteResourceDefinition(pool, rscName);
1205+
throw new CloudRuntimeException("Unable to get matching Linstor endpoint.");
12081206
}
12091207
} catch (ApiException exc) {
12101208
logger.error("copy template failed: ", exc);
@@ -1246,7 +1244,7 @@ private Answer copyVolume(DataObject srcData, DataObject dstData) {
12461244
answer = optEP.get().sendMessage(cmd);
12471245
}
12481246
else {
1249-
answer = new Answer(cmd, false, "Unable to get matching Linstor endpoint.");
1247+
throw new CloudRuntimeException("Unable to get matching Linstor endpoint.");
12501248
}
12511249
} catch (ApiException exc) {
12521250
logger.error("copy volume failed: ", exc);
@@ -1285,8 +1283,8 @@ private Answer copyFromTemporaryResource(
12851283
snapshotObject.setPath(devName);
12861284
origCmd.setSrcTO(snapshotObject.getTO());
12871285
answer = optEPAny.get().sendMessage(origCmd);
1288-
} else{
1289-
answer = new Answer(origCmd, false, "Unable to get matching Linstor endpoint.");
1286+
} else {
1287+
throw new CloudRuntimeException("Unable to get matching Linstor endpoint.");
12901288
}
12911289
} finally {
12921290
// delete the temporary resource, noop if already gone

0 commit comments

Comments
 (0)