Updated Branches:
  refs/heads/master c3df34826 -> 484d6c4eb

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.


Project: http://git-wip-us.apache.org/repos/asf/cloudstack/repo
Commit: http://git-wip-us.apache.org/repos/asf/cloudstack/commit/85dc65c7
Tree: http://git-wip-us.apache.org/repos/asf/cloudstack/tree/85dc65c7
Diff: http://git-wip-us.apache.org/repos/asf/cloudstack/diff/85dc65c7

Branch: refs/heads/master
Commit: 85dc65c7f766e76ff57816127578adca5ade1c54
Parents: c3df348
Author: Sheng Yang <[email protected]>
Authored: Thu Oct 17 18:16:50 2013 -0700
Committer: Sheng Yang <[email protected]>
Committed: Thu Oct 17 20:00:48 2013 -0700

----------------------------------------------------------------------
 .../VirtualNetworkApplianceManagerImpl.java     | 24 ++++++++++++++++++++
 .../debian/config/etc/init.d/cloud-early-config |  1 +
 2 files changed, 25 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cloudstack/blob/85dc65c7/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
----------------------------------------------------------------------
diff --git 
a/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java 
b/server/src/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
index 2ae2cfc..1958d1e 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<DomainRouterVO> 
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<DomainRouterVO> 
findOrDeployVirtualRouterInGuestNetwork(Network guestNetwork, DeployDestination 
dest, Account owner,
             boolean isRedundant, Map<Param, Object> 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

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/85dc65c7/systemvm/patches/debian/config/etc/init.d/cloud-early-config
----------------------------------------------------------------------
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 88ecc11..d44f94d 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"

Reply via email to