From a3e87cfa951a4905d8d5259840d6c751684df1d6 Mon Sep 17 00:00:00 2001 From: Prachi Damle Date: Thu, 20 Nov 2014 15:55:37 -0800 Subject: [PATCH] Bug-ID:CS-27160: Restore VM (Re-install VM) with enable.storage.migration set to false fails, later fails to start up VM too Reviewed-By: Anthony Changes: - Try to reuse the storage pools for READY disks if the pool fits the deployment plan - Try to use the last_host if it has free capacity but no reserved capacity Signed-off-by: Maneesha.P --- .../deploy/DeploymentPlanningManagerImpl.java | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java index 57abb9204c4..75bc4b523b0 100644 --- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -400,10 +400,21 @@ StateListener { "memoryOvercommitRatio"); Float cpuOvercommitRatio = Float.parseFloat(cluster_detail_cpu.getValue()); Float memoryOvercommitRatio = Float.parseFloat(cluster_detail_ram.getValue()); - if (_capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, true, - cpuOvercommitRatio, memoryOvercommitRatio, true) - && _capacityMgr.checkIfHostHasCpuCapability(host.getId(), offering.getCpu(), - offering.getSpeed())) { + + boolean hostHasCpuCapability, hostHasCapacity = false; + hostHasCpuCapability = _capacityMgr.checkIfHostHasCpuCapability(host.getId(), offering.getCpu(), offering.getSpeed()); + + if (hostHasCpuCapability) { + // first check from reserved capacity + hostHasCapacity = _capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, true, cpuOvercommitRatio, memoryOvercommitRatio, true); + + // if not reserved, check the free capacity + if (!hostHasCapacity) + hostHasCapacity = _capacityMgr.checkIfHostHasCapacity(host.getId(), cpu_requested, ram_requested, false, cpuOvercommitRatio, memoryOvercommitRatio, true); + } + + if (hostHasCapacity + && hostHasCpuCapability) { s_logger.debug("The last host of this VM is UP and has enough capacity"); s_logger.debug("Now checking for suitable pools under zone: " + host.getDataCenterId() + ", pod: " + host.getPodId() + ", cluster: " + host.getClusterId());