Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions server/src/main/java/com/cloud/capacity/CapacityManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adaptive breaks because it is managed storage and creates a real template copy on the array but its overriding method returns 0. So the template size will not get added for them

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, There are vendors who return getBytesRequiredForTemplate 0 which is called in getAskingSizeForTemplateBasedOnClusterAndStoragePool. But From the cloudstack perspective They are expected to implement these methods to provide their template size. Template size shouldn't be part of allocated size calculation as keeping it here will lead to double counting of template size for all vendors who have implemented getBytesRequiredForTemplate in driver.

} else {
// Get size for all the non-destroyed volumes.
Pair<Long, Long> sizes = _volumeDao.getNonDestroyedCountAndTotalByPool(pool.getId());
Expand Down
Loading