From aa62144d6ae669a13a44c37edae3106204105dea Mon Sep 17 00:00:00 2001 From: Wei Zhou Date: Thu, 17 Aug 2023 15:04:11 +0200 Subject: [PATCH] server: try with all supported hypervisors (ordered, no duplicatios) when deploy a virtual router --- .../java/com/cloud/network/router/NetworkHelperImpl.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/server/src/main/java/com/cloud/network/router/NetworkHelperImpl.java b/server/src/main/java/com/cloud/network/router/NetworkHelperImpl.java index 934336066ccf..8e3fe50660f6 100644 --- a/server/src/main/java/com/cloud/network/router/NetworkHelperImpl.java +++ b/server/src/main/java/com/cloud/network/router/NetworkHelperImpl.java @@ -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; @@ -502,7 +503,6 @@ public DomainRouterVO deployRouter(final RouterDeploymentDefinition routerDeploy // failed both times, throw the exception up final List hypervisors = getHypervisors(routerDeploymentDefinition); - int allocateRetry = 0; int startRetry = 0; DomainRouterVO router = null; for (final Iterator iter = hypervisors.iterator(); iter.hasNext();) { @@ -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) { @@ -618,7 +616,7 @@ protected List 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)); } /*