Copilot commented on code in PR #14071:
URL: https://github.com/apache/cloudstack/pull/14071#discussion_r3950219425
##########
server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java:
##########
@@ -1127,6 +1127,14 @@ 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);
+ Pair<Volume, DiskProfile> volumeDiskProfilePair = new Pair<>(volume,
diskProfile);
+ if
(!storageMgr.storagePoolHasEnoughSpace(Collections.singletonList(volumeDiskProfilePair),
storagePool)) {
+ throw new InvalidParameterValueException(String.format("Cannot
create volume %s on storage pool %s as the pool does not have enough space " +
+ "or has crossed the disable threshold.", volume.getUuid(),
storagePool.getName()));
+ }
+
DataStore dataStore = dataStoreMgr.getDataStore(storageId,
DataStoreRole.Primary);
Review Comment:
`createVolumeOnStoragePool` fetches the same primary datastore twice: once
at the start (cast to `StoragePool`) and again right before
`volFactory.getVolume(...)`. This is redundant and can lead to inconsistent
behavior if the second lookup returns a different instance (or null) than the
one already validated (status/zone/threshold).
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]