From 0de8921d575006beaa4cbf9fd01bfc540365eb23 Mon Sep 17 00:00:00 2001 From: nit Date: Mon, 20 Dec 2010 15:07:12 +0530 Subject: [PATCH] =?UTF-8?q?bug=205942,7164=20:=20For=20pool=20allocation?= =?UTF-8?q?=20calculation=20while=20creating=20vm=E2=80=99s=20we=20conside?= =?UTF-8?q?r=20templates=20but=20not=20on=20the=20dashboard=20-=20correcti?= =?UTF-8?q?ng=20that.=20=09=09While=20creating=20a=20vm=20if=20a=20pool=20?= =?UTF-8?q?is=20not=20adequate=20to=20create=20the=20vm's=20volume=20then?= =?UTF-8?q?=20improving=20the=20misleading=20verbiage=20of=20the=20log=20m?= =?UTF-8?q?essage.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/src/com/cloud/storage/StorageManager.java | 6 ++++++ server/src/com/cloud/alert/AlertManagerImpl.java | 1 + .../src/com/cloud/storage/StorageManagerImpl.java | 14 ++++++++++++++ .../allocator/AbstractStoragePoolAllocator.java | 3 ++- 4 files changed, 23 insertions(+), 1 deletion(-) diff --git a/core/src/com/cloud/storage/StorageManager.java b/core/src/com/cloud/storage/StorageManager.java index 276c3d721d4..172a7e462f9 100644 --- a/core/src/com/cloud/storage/StorageManager.java +++ b/core/src/com/cloud/storage/StorageManager.java @@ -24,6 +24,7 @@ import java.util.Map; import com.cloud.agent.api.Answer; import com.cloud.agent.api.Command; +import com.cloud.agent.api.to.VolumeTO; import com.cloud.dc.DataCenterVO; import com.cloud.dc.HostPodVO; import com.cloud.exception.InternalErrorException; @@ -274,4 +275,9 @@ public interface StorageManager extends Manager { void createCapacityEntry(StoragePoolVO storagePool, long allocated); + /** + * Calculates the sum of all template sizes in the pool. + */ + long calculateAllTemplateSizesInPool(StoragePoolVO pool); + } diff --git a/server/src/com/cloud/alert/AlertManagerImpl.java b/server/src/com/cloud/alert/AlertManagerImpl.java index 71883c71dcf..829ef1770af 100644 --- a/server/src/com/cloud/alert/AlertManagerImpl.java +++ b/server/src/com/cloud/alert/AlertManagerImpl.java @@ -381,6 +381,7 @@ public class AlertManagerImpl implements AlertManager { long disk = 0l; Pair sizes = _volumeDao.getCountAndTotalByPool(pool.getId()); disk = sizes.second(); + disk += _storageMgr.calculateAllTemplateSizesInPool(pool); _storageMgr.createCapacityEntry(pool, disk); } diff --git a/server/src/com/cloud/storage/StorageManagerImpl.java b/server/src/com/cloud/storage/StorageManagerImpl.java index 501be89f11c..b3da8aace8e 100644 --- a/server/src/com/cloud/storage/StorageManagerImpl.java +++ b/server/src/com/cloud/storage/StorageManagerImpl.java @@ -1651,6 +1651,20 @@ public class StorageManagerImpl implements StorageManager { s_logger.debug("Successfully set Capacity - " +storagePool.getCapacityBytes()* _overProvisioningFactor+ " for CAPACITY_TYPE_STORAGE_ALLOCATED, DataCenterId - " +storagePool.getDataCenterId()+ ", HostOrPoolId - " +storagePool.getId()+ ", PodId " +storagePool.getPodId()); } + @Override + //TO DO - use this in AbstractpoolAllocator.checkPool. + public long calculateAllTemplateSizesInPool(StoragePoolVO pool){ + List templatePoolVOs = _vmTemplatePoolDao.listByPoolId(pool.getId()); + long totalAllocatedSize = 0l; + long extraBytesPerVolume = 0l; + + for (VMTemplateStoragePoolVO templatePoolVO : templatePoolVOs) { + long templateSize = templatePoolVO.getTemplateSize(); + totalAllocatedSize += templateSize + extraBytesPerVolume; + } + return totalAllocatedSize; + } + @Override public Answer sendToHostsOnStoragePool(Long poolId, Command cmd, String basicErrMsg) { return sendToHostsOnStoragePool(poolId, cmd, basicErrMsg, 1, 0, false); diff --git a/server/src/com/cloud/storage/allocator/AbstractStoragePoolAllocator.java b/server/src/com/cloud/storage/allocator/AbstractStoragePoolAllocator.java index e4d88446147..3cd8c96a25b 100644 --- a/server/src/com/cloud/storage/allocator/AbstractStoragePoolAllocator.java +++ b/server/src/com/cloud/storage/allocator/AbstractStoragePoolAllocator.java @@ -173,6 +173,7 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement long totalAllocatedSize = sizes.second() + (long)sizes.first() * _extraBytesPerVolume; + // TO DO - abstract this out. The dashboard should also use the same calculation. (@AlertManagerImpl) // Iterate through all templates on this storage pool boolean tmpinstalled = false; List templatePoolVOs; @@ -213,7 +214,7 @@ public abstract class AbstractStoragePoolAllocator extends AdapterBase implement if ((pool.getCapacityBytes() * storageOverprovisioningFactor) < (totalAllocatedSize + askingSize)) { if (s_logger.isDebugEnabled()) { - s_logger.debug("Found pool " + pool.getId() + " for storage, maxSize : " + (pool.getCapacityBytes() * storageOverprovisioningFactor) + ", totalSize : " + totalAllocatedSize + ", askingSize : " + askingSize); + s_logger.debug("Pool " + pool.getId() + " doesnt have sufficient allocation bandwidth, with maxAllocationSize : " + (pool.getCapacityBytes() * storageOverprovisioningFactor) + ", totalAllocatedSize : " + totalAllocatedSize + ", askingAllocationSize : " + askingSize); } return false;