Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1127,7 +1127,9 @@ private VolumeVO createVolumeOnStoragePool(Long volumeId, Long storageId) throws
throw new InvalidParameterValueException(String.format("Disk offering: %s is not compatible with the storage pool", diskOffering.getUuid()));
}

if (!storageMgr.storagePoolHasEnoughSpace(volume.getSize(), storagePool)) {
HypervisorType hypervisorType = _volsDao.getHypervisorType(volume.getId());
DiskProfile diskProfile = new DiskProfile(volume, diskOffering, hypervisorType);
if (!storageMgr.storagePoolHasEnoughSpace(Collections.singletonList(new Pair<>(volume, diskProfile)), storagePool, storagePool.getClusterId())) {
throw new InvalidParameterValueException(String.format("Storage pool %s does not have enough space to create volume %s.",
storagePool.getName(), volume.getUuid()));
}
Expand Down Expand Up @@ -1189,6 +1191,9 @@ public VolumeVO createVolume(long volumeId, Long vmId, Long snapshotId, Long sto
created = false;
VolumeInfo vol = volFactory.getVolume(volumeId);
vol.stateTransit(Volume.Event.DestroyRequested);
if (e instanceof InvalidParameterValueException) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for handling this separately?

throw (InvalidParameterValueException) e;
}
throw new CloudRuntimeException(String.format("Failed to create volume: %s", volume), e);
} finally {
if (!created) {
Expand Down
Loading