2828
2929import com .cloud .agent .api .to .DiskTO ;
3030import com .cloud .storage .VolumeVO ;
31- import com .cloud .utils .exception .CloudRuntimeException ;
3231import org .apache .cloudstack .engine .subsystem .api .storage .ChapInfo ;
3332import org .apache .cloudstack .engine .subsystem .api .storage .CopyCommandResult ;
3433import 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