Bug 11131 - Allocators: when vm fails to deploy in DataCenter, we should never retry in the same DC again as the DC is already in Avoid set

Changes:
- Added check in planner to verfiy that the datacenter is not in avoid set. If found in avoid set, planner does not proceed.
This commit is contained in:
prachi 2011-11-23 17:39:55 -08:00
parent 7402ff0b8c
commit 8134cfb4c8
2 changed files with 19 additions and 3 deletions

View File

@ -246,7 +246,14 @@ public interface DeploymentPlanner extends Adapter {
return false;
}
public boolean shouldAvoid(DataCenter dc) {
if (_dcIds != null && _dcIds.contains(dc.getId())) {
return true;
}
return false;
}
public Set<Long> getDataCentersToAvoid(){
return _dcIds;
}
@ -265,6 +272,6 @@ public interface DeploymentPlanner extends Adapter {
public Set<Long> getPoolsToAvoid(){
return _poolIds;
}
}
}
}

View File

@ -113,8 +113,17 @@ public class FirstFitPlanner extends PlannerBase implements DeploymentPlanner {
DeploymentPlan plan, ExcludeList avoid)
throws InsufficientServerCapacityException {
VirtualMachine vm = vmProfile.getVirtualMachine();
ServiceOffering offering = vmProfile.getServiceOffering();
DataCenter dc = _dcDao.findById(vm.getDataCenterIdToDeployIn());
//check if datacenter is in avoid set
if(avoid.shouldAvoid(dc)){
if (s_logger.isDebugEnabled()) {
s_logger.debug("DataCenter id = '"+ dc.getId() +"' provided is in avoid set, DeploymentPlanner cannot allocate the VM, returning.");
}
return null;
}
ServiceOffering offering = vmProfile.getServiceOffering();
int cpu_requested = offering.getCpu() * offering.getSpeed();
long ram_requested = offering.getRamSize() * 1024L * 1024L;