From ab9fd56a9cc323aefecf09639f1f8cf3ae8da003 Mon Sep 17 00:00:00 2001 From: sr73318 Date: Thu, 15 Oct 2026 18:32:34 +0530 Subject: [PATCH] CSTACKEX-337: fixing the bug for First VM deployment double-counts the template size when calculating the minimum primary storagepool size required by removing template size being added in allocatedpoolcapacity --- .../com/cloud/capacity/CapacityManagerImpl.java | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java b/server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java index 3be7384ffb71..6f52d83b80e3 100644 --- a/server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java +++ b/server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java @@ -580,18 +580,7 @@ public long getAllocatedPoolCapacity(StoragePoolVO pool, VMTemplateVO templateFo // if the storage pool is managed, the used bytes can be larger than the sum of the sizes of all of the non-destroyed volumes // in this case, call getUsedBytes(StoragePoolVO) if (pool.isManaged()) { - totalAllocatedSize = getUsedBytes(pool); - - if (templateForVmCreation != null) { - VMTemplateStoragePoolVO templatePoolVO = _templatePoolDao.findByPoolTemplate(pool.getId(), templateForVmCreation.getId(), null); - if (templatePoolVO == null) { - // template is not installed in the pool, consider the template size for allocation - long templateForVmCreationSize = templateForVmCreation.getSize() != null ? templateForVmCreation.getSize() : 0; - totalAllocatedSize += templateForVmCreationSize; - } - } - - return totalAllocatedSize; + return getUsedBytes(pool); } else { // Get size for all the non-destroyed volumes. Pair sizes = _volumeDao.getNonDestroyedCountAndTotalByPool(pool.getId());