slavkap commented on code in PR #14442:
URL: https://github.com/apache/cloudstack/pull/14442#discussion_r4781623324
##########
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:
StorPool isn't affected: its pools are created with managed=false, and the
unmanaged branch of `getAllocatedPoolCapacity` is unchanged. For managed pools
the change looks correct, since the template is still counted once in
`totalAskingSize` whenever it's needed on the pool. A unit test for a managed
pool with a template that isn't on the pool yet would be nice.
code LGTM
--
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]