From 85dc65c7f766e76ff57816127578adca5ade1c54 Mon Sep 17 00:00:00 2001 From: Sheng Yang Date: Thu, 17 Oct 2013 18:16:50 -0700 Subject: [PATCH] CLOUDSTACK-4786: Reset Redundant Router priority after all the routers are stopped This patch would reset the priority in such condition: 1. All redundant routers are stopped, e.g. due to network GC 2. User start one VM in the network 3. The routers would be brought up with reseted priority(100 & 99). This would resolve the issue of network GC result in lower limit of redundant router priority reached. --- .../VirtualNetworkApplianceManagerImpl.java | 24 +++++++++++++++++++ .../config/etc/init.d/cloud-early-config | 1 + 2 files changed, 25 insertions(+) diff --git a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java index 2ae2cfc6260..1958d1ef75a 100755 --- a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java +++ b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java @@ -1412,6 +1412,26 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V throw new CloudRuntimeException(errMsg); } + private void checkAndResetPriorityOfRedundantRouter(List routers) { + boolean allStopped = true; + for (DomainRouterVO router : routers) { + if (!router.getIsRedundantRouter() || router.getState() != VirtualMachine.State.Stopped) { + allStopped = false; + break; + } + } + if (!allStopped) { + return; + } + + for (DomainRouterVO router : routers) { + // getUpdatedPriority() would update the value later + router.setPriority(0); + router.setIsPriorityBumpUp(false); + _routerDao.update(router.getId(), router); + } + } + @DB protected List findOrDeployVirtualRouterInGuestNetwork(Network guestNetwork, DeployDestination dest, Account owner, boolean isRedundant, Map params) throws ConcurrentOperationException, @@ -1482,6 +1502,10 @@ public class VirtualNetworkApplianceManagerImpl extends ManagerBase implements V int routerCount = 1; if (isRedundant) { routerCount = 2; + //Check current redundant routers, if possible(all routers are stopped), reset the priority + if (routers.size() != 0) { + checkAndResetPriorityOfRedundantRouter(routers); + } } // If old network is redundant but new is single router, then routers.size() = 2 but routerCount = 1 diff --git a/systemvm/patches/debian/config/etc/init.d/cloud-early-config b/systemvm/patches/debian/config/etc/init.d/cloud-early-config index 88ecc119b61..d44f94d7d17 100755 --- a/systemvm/patches/debian/config/etc/init.d/cloud-early-config +++ b/systemvm/patches/debian/config/etc/init.d/cloud-early-config @@ -1189,6 +1189,7 @@ change_password() { start() { # Clear /tmp for file lock rm -f /tmp/*.lock + rm -f /tmp/rrouter_bumped local hyp=$(hypervisor) [ $? -ne 0 ] && log_it "Failed to detect hypervisor type, bailing out of early init" && exit 10 log_it "Detected that we are running inside $hyp guest"