rajiv-jain-netapp commented on code in PR #14442:
URL: https://github.com/apache/cloudstack/pull/14442#discussion_r4704452661


##########
server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java:
##########
@@ -573,25 +573,16 @@ public long getUsedIops(StoragePoolVO pool) {
         throw new CloudRuntimeException("Storage driver in 
CapacityManagerImpl.getUsedIops(StoragePoolVO) is not a 
PrimaryDataStoreDriver.");
     }
 
+    //Managed pool, return value contains used size of the pool.
+    //Unmanaged pool, return value contains used pool size and template size.
     @Override
     public long getAllocatedPoolCapacity(StoragePoolVO pool, VMTemplateVO 
templateForVmCreation) {
         long totalAllocatedSize;
 
         // 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);

Review Comment:
   Just to give context @nvazquez  @sureshanaparti 
   
   In the previous code, allocatedSize is first retrieved at line 583, and the 
template size is added to it at line 590. In the outer method, the template 
size was added again while validating whether sufficient capacity was 
available. As a result, the template size was counted twice during the capacity 
validation.
   
   Fix: Removed the additional template size calculation from the outer method 
to avoid double-counting.



-- 
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]

Reply via email to