Skip to content

Commit 8d2b008

Browse files
update the resize error through callback result instead of exception
1 parent e8df773 commit 8d2b008

File tree

2 files changed

+7
-11
lines changed

2 files changed

+7
-11
lines changed

engine/storage/volume/src/main/java/org/apache/cloudstack/storage/volume/VolumeServiceImpl.java

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2548,7 +2548,7 @@ protected Void resizeVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, C
25482548
try {
25492549
volume.processEvent(Event.OperationFailed);
25502550
} catch (Exception e) {
2551-
s_logger.debug("Failed to change state", e);
2551+
s_logger.debug("Failed to change volume state (after resize failure)", e);
25522552
}
25532553
VolumeApiResult res = new VolumeApiResult(volume);
25542554
res.setResult(result.getResult());
@@ -2559,13 +2559,8 @@ protected Void resizeVolumeCallback(AsyncCallbackDispatcher<VolumeServiceImpl, C
25592559
try {
25602560
volume.processEvent(Event.OperationSuccessed);
25612561
} catch (Exception e) {
2562-
s_logger.debug("Failed to change state", e);
2563-
VolumeApiResult res = new VolumeApiResult(volume);
2564-
res.setResult(result.getResult());
2565-
future.complete(res);
2566-
return null;
2562+
s_logger.debug("Failed to change volume state (after resize success)", e);
25672563
}
2568-
25692564
VolumeApiResult res = new VolumeApiResult(volume);
25702565
future.complete(res);
25712566

plugins/storage/volume/default/src/main/java/org/apache/cloudstack/storage/datastore/driver/CloudStackPrimaryDataStoreDriverImpl.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828

2929
import com.cloud.agent.api.to.DiskTO;
3030
import com.cloud.storage.VolumeVO;
31-
import com.cloud.utils.exception.CloudRuntimeException;
3231
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
3332
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
3433
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
@@ -430,13 +429,17 @@ public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> cal
430429
boolean encryptionRequired = anyVolumeRequiresEncryption(vol);
431430
long [] endpointsToRunResize = resizeParameter.hosts;
432431

432+
CreateCmdResult result = new CreateCmdResult(null, null);
433+
433434
// if hosts are provided, they are where the VM last ran. We can use that.
434435
if (endpointsToRunResize == null || endpointsToRunResize.length == 0) {
435436
EndPoint ep = epSelector.select(data, encryptionRequired);
436437
if (ep == null) {
437438
String errMsg = String.format(NO_REMOTE_ENDPOINT_WITH_ENCRYPTION, encryptionRequired);
438439
s_logger.error(errMsg);
439-
throw new CloudRuntimeException(errMsg);
440+
result.setResult(errMsg);
441+
callback.complete(result);
442+
return;
440443
}
441444
endpointsToRunResize = new long[] {ep.getId()};
442445
}
@@ -445,7 +448,6 @@ public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> cal
445448
if (pool.getParent() != 0) {
446449
resizeCmd.setContextParam(DiskTO.PROTOCOL_TYPE, Storage.StoragePoolType.DatastoreCluster.toString());
447450
}
448-
CreateCmdResult result = new CreateCmdResult(null, null);
449451
try {
450452
ResizeVolumeAnswer answer = (ResizeVolumeAnswer) storageMgr.sendToPool(pool, endpointsToRunResize, resizeCmd);
451453
if (answer != null && answer.getResult()) {
@@ -462,7 +464,6 @@ public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> cal
462464
s_logger.debug("return a null answer, mark it as failed for unknown reason");
463465
result.setResult("return a null answer, mark it as failed for unknown reason");
464466
}
465-
466467
} catch (Exception e) {
467468
s_logger.debug("sending resize command failed", e);
468469
result.setResult(e.toString());

0 commit comments

Comments
 (0)