diff --git a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java index 471225f04c4..8b7ed877877 100644 --- a/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java +++ b/server/src/com/cloud/deploy/DeploymentPlanningManagerImpl.java @@ -322,8 +322,9 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy if (!suitableVolumeStoragePools.isEmpty()) { List suitableHosts = new ArrayList(); suitableHosts.add(host); - Pair> potentialResources = - findPotentialDeploymentResources(suitableHosts, suitableVolumeStoragePools, avoids, getPlannerUsage(planner, vmProfile, plan, avoids)); + Pair> potentialResources = findPotentialDeploymentResources( + suitableHosts, suitableVolumeStoragePools, avoids, + getPlannerUsage(planner, vmProfile, plan, avoids), readyAndReusedVolumes); if (potentialResources != null) { Pod pod = _podDao.findById(host.getPodId()); Cluster cluster = _clusterDao.findById(host.getClusterId()); @@ -379,8 +380,9 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy if (!suitableVolumeStoragePools.isEmpty()) { List suitableHosts = new ArrayList(); suitableHosts.add(host); - Pair> potentialResources = - findPotentialDeploymentResources(suitableHosts, suitableVolumeStoragePools, avoids, getPlannerUsage(planner, vmProfile, plan, avoids)); + Pair> potentialResources = findPotentialDeploymentResources( + suitableHosts, suitableVolumeStoragePools, avoids, + getPlannerUsage(planner, vmProfile, plan, avoids), readyAndReusedVolumes); if (potentialResources != null) { Pod pod = _podDao.findById(host.getPodId()); Cluster cluster = _clusterDao.findById(host.getClusterId()); @@ -881,8 +883,9 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy // choose the potential host and pool for the VM if (!suitableVolumeStoragePools.isEmpty()) { - Pair> potentialResources = - findPotentialDeploymentResources(suitableHosts, suitableVolumeStoragePools, avoid, resourceUsageRequired); + Pair> potentialResources = findPotentialDeploymentResources( + suitableHosts, suitableVolumeStoragePools, avoid, resourceUsageRequired, + readyAndReusedVolumes); if (potentialResources != null) { Pod pod = _podDao.findById(clusterVO.getPodId()); @@ -1008,11 +1011,15 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy } protected Pair> findPotentialDeploymentResources(List suitableHosts, Map> suitableVolumeStoragePools, - ExcludeList avoid, DeploymentPlanner.PlannerResourceUsage resourceUsageRequired) { + ExcludeList avoid, DeploymentPlanner.PlannerResourceUsage resourceUsageRequired, List readyAndReusedVolumes) { s_logger.debug("Trying to find a potenial host and associated storage pools from the suitable host/pool lists for this VM"); boolean hostCanAccessPool = false; boolean haveEnoughSpace = false; + + if (readyAndReusedVolumes == null) { + readyAndReusedVolumes = new ArrayList(); + } Map storage = new HashMap(); TreeSet volumesOrderBySizeDesc = new TreeSet(new Comparator() { @Override @@ -1035,7 +1042,7 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy for (StoragePool potentialSPool : volumePoolList) { if (hostCanAccessSPool(potentialHost, potentialSPool)) { hostCanAccessPool = true; - if (multipleVolume) { + if (multipleVolume && !readyAndReusedVolumes.contains(vol)) { List requestVolumes = null; if (volumeAllocationMap.containsKey(potentialSPool)) requestVolumes = volumeAllocationMap.get(potentialSPool);