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
10 changes: 10 additions & 0 deletions server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1127,6 +1127,13 @@ 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()));
}

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()));
Comment thread
sp16743 marked this conversation as resolved.
}

DataStore dataStore = dataStoreMgr.getDataStore(storageId, DataStoreRole.Primary);
VolumeInfo volumeInfo = volFactory.getVolume(volumeId, dataStore);
AsyncCallFuture<VolumeApiResult> createVolumeFuture = volService.createVolumeAsync(volumeInfo, dataStore);
Expand Down Expand Up @@ -1184,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) {
throw (InvalidParameterValueException) e;
}
throw new CloudRuntimeException(String.format("Failed to create volume: %s", volume), e);
} finally {
if (!created) {
Expand Down