CLOUDSTACK-5426: Cannot deploy instance having multiple volumes that use different storage tags for storage pools in same cluster

Changes:
- We need to reset the avoid set to its original state while calling the storage pool allocators for each volume.
- This will prevent affecting allocation of the disks due to the avoid set output of the prior disk allocations.
This commit is contained in:
Prachi Damle 2013-12-09 14:08:16 -08:00
parent 33ff20e1c3
commit 6df86db230
1 changed files with 18 additions and 0 deletions

View File

@ -19,8 +19,10 @@ package com.cloud.deploy;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.Timer;
import java.util.TreeSet;
@ -1128,6 +1130,12 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
// for each volume find list of suitable storage pools by calling the
// allocators
Set<Long> originalAvoidPoolSet = avoid.getPoolsToAvoid();
if (originalAvoidPoolSet == null) {
originalAvoidPoolSet = new HashSet<Long>();
}
Set<Long> poolsToAvoidOutput = new HashSet<Long>(originalAvoidPoolSet);
for (VolumeVO toBeCreated : volumesTobeCreated) {
s_logger.debug("Checking suitable pools for volume (Id, Type): (" + toBeCreated.getId() + ","
+ toBeCreated.getVolumeType().name() + ")");
@ -1241,6 +1249,10 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
break;
}
}
if (avoid.getPoolsToAvoid() != null) {
poolsToAvoidOutput.addAll(avoid.getPoolsToAvoid());
avoid.getPoolsToAvoid().retainAll(originalAvoidPoolSet);
}
if (!foundPotentialPools) {
s_logger.debug("No suitable pools found for volume: " + toBeCreated + " under cluster: "
@ -1253,6 +1265,12 @@ public class DeploymentPlanningManagerImpl extends ManagerBase implements Deploy
break;
}
}
if (suitableVolumeStoragePools.values() != null) {
poolsToAvoidOutput.removeAll(suitableVolumeStoragePools.values());
}
if (avoid.getPoolsToAvoid() != null) {
avoid.getPoolsToAvoid().addAll(poolsToAvoidOutput);
}
if (suitableVolumeStoragePools.isEmpty()) {
s_logger.debug("No suitable pools found");