Skip to content

Commit 8134cfb

Browse files
author
prachi
committed
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.
1 parent 7402ff0 commit 8134cfb

2 files changed

Lines changed: 19 additions & 3 deletions

File tree

‎api/src/com/cloud/deploy/DeploymentPlanner.java‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,14 @@ public boolean shouldAvoid(StoragePool pool) {
246246

247247
return false;
248248
}
249-
249+
250+
public boolean shouldAvoid(DataCenter dc) {
251+
if (_dcIds != null && _dcIds.contains(dc.getId())) {
252+
return true;
253+
}
254+
return false;
255+
}
256+
250257
public Set<Long> getDataCentersToAvoid(){
251258
return _dcIds;
252259
}
@@ -265,6 +272,6 @@ public Set<Long> getHostsToAvoid(){
265272

266273
public Set<Long> getPoolsToAvoid(){
267274
return _poolIds;
268-
}
275+
}
269276
}
270277
}

‎server/src/com/cloud/deploy/FirstFitPlanner.java‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,17 @@ public DeployDestination plan(VirtualMachineProfile<? extends VirtualMachine> vm
113113
DeploymentPlan plan, ExcludeList avoid)
114114
throws InsufficientServerCapacityException {
115115
VirtualMachine vm = vmProfile.getVirtualMachine();
116-
ServiceOffering offering = vmProfile.getServiceOffering();
117116
DataCenter dc = _dcDao.findById(vm.getDataCenterIdToDeployIn());
117+
118+
//check if datacenter is in avoid set
119+
if(avoid.shouldAvoid(dc)){
120+
if (s_logger.isDebugEnabled()) {
121+
s_logger.debug("DataCenter id = '"+ dc.getId() +"' provided is in avoid set, DeploymentPlanner cannot allocate the VM, returning.");
122+
}
123+
return null;
124+
}
125+
126+
ServiceOffering offering = vmProfile.getServiceOffering();
118127
int cpu_requested = offering.getCpu() * offering.getSpeed();
119128
long ram_requested = offering.getRamSize() * 1024L * 1024L;
120129

0 commit comments

Comments
 (0)