From 0d9a0678120e066ec2cb251c8ec95dc175334178 Mon Sep 17 00:00:00 2001 From: sp16743 Date: Wed, 14 Oct 2026 18:17:54 +0530 Subject: [PATCH 1/2] CSTACKEX-345: validate storage pool capacity for volume creation --- .../main/java/com/cloud/storage/VolumeApiServiceImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java index 4e08100fec64..f7899d68fc30 100644 --- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java @@ -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)) { throw new InvalidParameterValueException(String.format("Storage pool %s does not have enough space to create volume %s.", storagePool.getName(), volume.getUuid())); } @@ -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) { + throw (InvalidParameterValueException) e; + } throw new CloudRuntimeException(String.format("Failed to create volume: %s", volume), e); } finally { if (!created) { From 1abc1a179cb17961b8e906d97808733f2831fdad Mon Sep 17 00:00:00 2001 From: sp16743 Date: Wed, 14 Oct 2026 22:42:15 +0530 Subject: [PATCH 2/2] pass the storage pool cluster id into the create-volume capacity check --- .../src/main/java/com/cloud/storage/VolumeApiServiceImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java index f7899d68fc30..f456febb8623 100644 --- a/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java +++ b/server/src/main/java/com/cloud/storage/VolumeApiServiceImpl.java @@ -1129,7 +1129,7 @@ private VolumeVO createVolumeOnStoragePool(Long volumeId, Long storageId) throws HypervisorType hypervisorType = _volsDao.getHypervisorType(volume.getId()); DiskProfile diskProfile = new DiskProfile(volume, diskOffering, hypervisorType); - if (!storageMgr.storagePoolHasEnoughSpace(Collections.singletonList(new Pair<>(volume, diskProfile)), storagePool)) { + 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())); }