From 4705933a6459c1b25e71da891a6f736c0a736836 Mon Sep 17 00:00:00 2001 From: Anshul Gangwar Date: Mon, 20 Oct 2014 16:04:25 +0530 Subject: [PATCH] CLOUDSTACK-7703, CLOUDSTACK-7752: Fixed deployment planner stuck in infinite loop. If we create VM with shared service offering and attach disk with local disk offering, and one of storage pool is full(cannot be allocated) and other is not full then we are not putting the cluster in avoid list which is causing this infinite loop. Fixed by putting the cluster in avoid list even if one of the storage pool is full(cannot be allocated) --- .../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 bfb33b0c6247..6b80dbad1cd3 100755 --- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -31,7 +31,6 @@ import javax.inject.Inject; import javax.naming.ConfigurationException; -import com.cloud.utils.fsm.StateMachine2; import org.apache.log4j.Logger; import org.apache.cloudstack.affinity.AffinityGroupProcessor; @@ -121,6 +120,7 @@ import com.cloud.utils.db.TransactionStatus; import com.cloud.utils.exception.CloudRuntimeException; import com.cloud.utils.fsm.StateListener; +import com.cloud.utils.fsm.StateMachine2; import com.cloud.vm.DiskProfile; import com.cloud.vm.VMInstanceVO; import com.cloud.vm.VirtualMachine; @@ -990,7 +990,10 @@ private boolean canAvoidCluster(Cluster clusterVO, ExcludeList avoids, ExcludeLi // if all hosts or all pools in the cluster are in avoid set after this // pass, then put the cluster in avoid set. - boolean avoidAllHosts = true, avoidAllPools = true; + boolean avoidAllHosts = true; + boolean avoidAllPools = true; + boolean avoidAllLocalPools = true; + boolean avoidAllSharedPools = true; List allhostsInCluster = _hostDao.listAllUpAndEnabledNonHAHosts(Host.Type.Routing, clusterVO.getId(), clusterVO.getPodId(), clusterVO.getDataCenterId(), null); @@ -1024,7 +1027,7 @@ private boolean canAvoidCluster(Cluster clusterVO, ExcludeList avoids, ExcludeLi for (StoragePoolVO pool : allPoolsInCluster) { if (!allocatorAvoidOutput.shouldAvoid(pool)) { // there's some pool in the cluster that is not yet in avoid set - avoidAllPools = false; + avoidAllSharedPools = false; break; } } @@ -1038,11 +1041,19 @@ private boolean canAvoidCluster(Cluster clusterVO, ExcludeList avoids, ExcludeLi if (!allocatorAvoidOutput.shouldAvoid(pool)) { // there's some pool in the cluster that is not yet // in avoid set - avoidAllPools = false; + avoidAllLocalPools = false; break; } } } + + if (vmRequiresSharedStorage && vmRequiresLocalStorege) { + avoidAllPools = (avoidAllLocalPools || avoidAllSharedPools) ? true : false; + } else if (vmRequiresSharedStorage) { + avoidAllPools = avoidAllSharedPools; + } else if (vmRequiresLocalStorege) { + avoidAllPools = avoidAllLocalPools; + } } if (avoidAllHosts || avoidAllPools) {