Skip to content

Commit

Permalink
server: try with all supported hypervisors (ordered, no duplicatios) …
Browse files Browse the repository at this point in the history
…when deploy a virtual router
  • Loading branch information
weizhouapache committed Aug 17, 2023
1 parent d8a5c89 commit aa62144
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;

Expand Down Expand Up @@ -502,7 +503,6 @@ public DomainRouterVO deployRouter(final RouterDeploymentDefinition routerDeploy
// failed both times, throw the exception up
final List<HypervisorType> hypervisors = getHypervisors(routerDeploymentDefinition);

int allocateRetry = 0;
int startRetry = 0;
DomainRouterVO router = null;
for (final Iterator<HypervisorType> iter = hypervisors.iterator(); iter.hasNext();) {
Expand Down Expand Up @@ -547,14 +547,12 @@ public DomainRouterVO deployRouter(final RouterDeploymentDefinition routerDeploy
reallocateRouterNetworks(routerDeploymentDefinition, router, template, null);
router = _routerDao.findById(router.getId());
} catch (final InsufficientCapacityException ex) {
if (allocateRetry < 2 && iter.hasNext()) {
if (iter.hasNext()) {
s_logger.debug("Failed to allocate the VR with hypervisor type " + hType + ", retrying one more time");
continue;
} else {
throw ex;
}
} finally {
allocateRetry++;
}

if (startRouter) {
Expand Down Expand Up @@ -618,7 +616,7 @@ protected List<HypervisorType> getHypervisors(final RouterDeploymentDefinition r
throw new InsufficientServerCapacityException("Unable to create virtual router, there are no clusters in the zone." + getNoHypervisorsErrMsgDetails(),
DataCenter.class, dest.getDataCenter().getId());
}
return hypervisors;
return new ArrayList(new LinkedHashSet<>(hypervisors));
}

/*
Expand Down

0 comments on commit aa62144

Please sign in to comment.