sathvikaragi opened a new issue, #14444:
URL: https://github.com/apache/cloudstack/issues/14444

   ### problem
   
   Deploying the first VM from a template onto a managed primary storage pool 
can fail the capacity check even when the pool has room for the volume and one 
copy of the template.
   
   StorageManagerImpl.storagePoolHasEnoughSpace adds the template size in two 
places when the template is not yet on the pool (no template_spool_ref row) and 
clusterId is set:
   
   CapacityManagerImpl.getAllocatedPoolCapacity calls getUsedBytes(pool), then 
adds templateForVmCreation.getSize().
   getAskingSizeForTemplateBasedOnClusterAndStoragePool calls 
getBytesRequiredForTemplate, which adds the template size again.
   The volume size is also added by 
getDataObjectSizeIncludingHypervisorSnapshotReserve. The check is therefore 
used bytes + template + volume + template. Unmanaged pools are unaffected: the 
template is added only inside getAllocatedPoolCapacity, because 
getAskingSizeForTemplateBasedOnClusterAndStoragePool returns 0 for them.
   
   ### versions
   
   The versions of ACS, hypervisors, storage, network etc..
   4.23
   
   ### The steps to reproduce the bug
   
   1.Use a managed primary pool whose free space can hold the root volume plus 
one copy of the template, but not two copies. 
   Example: If you wanna use a CentOS template(8 GiB) Try to create a pool of 
size 16GiB ( 8 for root disk, 8 for template) 
   2.Use a template that is not yet cached on the pool.
   3.Deploy a VM from that template on that pool.Storagepoolhasenoughspace 
rejects it.
   
   
   It will only allow to create a Vm if a pool is of size 24 GiB available 
space or more
   
   ### What to do about it?
   
   Before 
[apache/cloudstack#4304](https://github.com/apache/cloudstack/pull/4304/changes#diff-cfe46d82709b49e5c056c27f143595b1292ac4385abadd8115e3f25b8a762c32),
 a managed pool already behaved correctly. getAllocatedPoolCapacity returned 
only getUsedBytes(pool). The template was counted once, later, as part of the 
asking size in storagePoolHasEnoughSpace.
   
   That PR replaced the early return with extra logic: if templateForVmCreation 
is set and _templatePoolDao.findByPoolTemplate finds no template_spool_ref row, 
add templateForVmCreation.getSize() on top of getUsedBytes(pool). That is the 
block that has to be removed. The unmanaged branch should stay as it is.
   
   Restore the managed branch to:
   
   if (pool.isManaged()) {
       return getUsedBytes(pool);
   }
   storagePoolHasEnoughSpace still adds the template through 
getAskingSizeForTemplateBasedOnClusterAndStoragePool when the pool is managed, 
clusterId is set, and the template is not already on the pool. With the #4304 
addition gone, the check is used bytes + volume + template, which is what it 
was before that change.


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