Skip to content

Commit e8df773

Browse files
endpoint check for resize
1 parent d99dcff commit e8df773

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2491,7 +2491,7 @@ public AsyncCallFuture<VolumeApiResult> resize(VolumeInfo volume) {
24912491
try {
24922492
volume.processEvent(Event.ResizeRequested);
24932493
} catch (Exception e) {
2494-
s_logger.debug("Failed to change state to resize", e);
2494+
s_logger.debug("Failed to change volume state to resize", e);
24952495
result.setResult(e.toString());
24962496
future.complete(result);
24972497
return future;
@@ -2503,10 +2503,8 @@ public AsyncCallFuture<VolumeApiResult> resize(VolumeInfo volume) {
25032503
try {
25042504
volume.getDataStore().getDriver().resize(volume, caller);
25052505
} catch (Exception e) {
2506-
s_logger.debug("Failed to change state to resize", e);
2507-
2506+
s_logger.debug("Failed to resize volume", e);
25082507
result.setResult(e.toString());
2509-
25102508
future.complete(result);
25112509
}
25122510

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

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

2929
import com.cloud.agent.api.to.DiskTO;
3030
import com.cloud.storage.VolumeVO;
31+
import com.cloud.utils.exception.CloudRuntimeException;
3132
import org.apache.cloudstack.engine.subsystem.api.storage.ChapInfo;
3233
import org.apache.cloudstack.engine.subsystem.api.storage.CopyCommandResult;
3334
import org.apache.cloudstack.engine.subsystem.api.storage.CreateCmdResult;
@@ -432,6 +433,11 @@ public void resize(DataObject data, AsyncCompletionCallback<CreateCmdResult> cal
432433
// if hosts are provided, they are where the VM last ran. We can use that.
433434
if (endpointsToRunResize == null || endpointsToRunResize.length == 0) {
434435
EndPoint ep = epSelector.select(data, encryptionRequired);
436+
if (ep == null) {
437+
String errMsg = String.format(NO_REMOTE_ENDPOINT_WITH_ENCRYPTION, encryptionRequired);
438+
s_logger.error(errMsg);
439+
throw new CloudRuntimeException(errMsg);
440+
}
435441
endpointsToRunResize = new long[] {ep.getId()};
436442
}
437443
ResizeVolumeCommand resizeCmd = new ResizeVolumeCommand(vol.getPath(), new StorageFilerTO(pool), vol.getSize(),

0 commit comments

Comments
 (0)