[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-9114?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16435352#comment-16435352
 ] 

ASF GitHub Bot commented on CLOUDSTACK-9114:
--------------------------------------------

nitin-maharana commented on a change in pull request #2508: CLOUDSTACK-9114: 
Reduce VR downtime during network restart
URL: https://github.com/apache/cloudstack/pull/2508#discussion_r181043216
 
 

 ##########
 File path: 
engine/orchestration/src/org/apache/cloudstack/engine/orchestration/NetworkOrchestrator.java
 ##########
 @@ -2868,6 +2849,89 @@ public boolean restartNetwork(final Long networkId, 
final Account callerAccount,
         }
     }
 
+    @Override
+    public void destroyExpendableRouters(final List<? extends VirtualRouter> 
routers, final ReservationContext context) throws ResourceUnavailableException {
+        final List<VirtualRouter> remainingRouters = new ArrayList<>();
+        // Purge invalid routers
+        for (final VirtualRouter router : routers) {
+            if (router.getState() == VirtualMachine.State.Stopped ||
+                    router.getState() == VirtualMachine.State.Error ||
+                    router.getState() == VirtualMachine.State.Shutdowned ||
+                    router.getState() == VirtualMachine.State.Unknown) {
+                s_logger.debug("Destroying old router " + router);
+                _routerService.destroyRouter(router.getId(), 
context.getAccount(), context.getCaller().getId());
+            } else {
+                remainingRouters.add(router);
+            }
+        }
+
+        if (remainingRouters.size() < 2) {
+            return;
+        }
+
+        // Purge any backup router
+        VirtualRouter backupRouter = null;
+        for (final VirtualRouter router : remainingRouters) {
+            if (router.getRedundantState() == 
VirtualRouter.RedundantState.BACKUP) {
+                backupRouter = router;
+            }
+        }
+        if (backupRouter == null) {
+            backupRouter = routers.get(routers.size() - 1);
+        }
+        if (backupRouter != null) {
+            _routerService.destroyRouter(backupRouter.getId(), 
context.getAccount(), context.getCaller().getId());
+        }
+    }
+
+    @Override
+    public boolean validateNewRouters(final List<? extends VirtualRouter> 
routers, final boolean isRedundant) {
+        for (final VirtualRouter router : routers) {
+            if (router.getState() != VirtualMachine.State.Running) {
+                s_logger.debug("Found new router " + router.getInstanceName() 
+ " to be in non-Running state: " + router.getState() + ". Please try 
restarting network again.");
+                return false;
+            }
+            if (!isRedundant) {
+                
router.setRedundantState(VirtualRouter.RedundantState.REDUNDANT_CAPABLE);
+                _routerDao.update(router.getId(), (DomainRouterVO) router);
+            }
+        }
+        return true;
+    }
+
+    private boolean rollingRestartRouters(final NetworkVO network, final 
NetworkOffering offering, final DeployDestination dest, final 
ReservationContext context) throws ResourceUnavailableException, 
ConcurrentOperationException, InsufficientCapacityException {
+        s_logger.debug("Performing rolling restart of routers of network " + 
network);
+        destroyExpendableRouters(_routerDao.findByNetwork(network.getId()), 
context);
+
+        final List<Provider> providersToImplement = 
getNetworkProviders(network.getId());
+        final List<DomainRouterVO> oldRouters = 
_routerDao.findByNetwork(network.getId());
+
+        // Deploy a new router
+        final boolean originalRedundancy = network.isRedundant();
+        network.setRedundant(true);
+        implementNetworkElements(dest, context, network, offering, 
providersToImplement);
+        network.setRedundant(originalRedundancy);
+
+        // For redundant network wait for 3*advert_int+skew_seconds for VRRP 
to kick in
+        if (network.isRedundant() || (oldRouters.size() == 1 && 
oldRouters.get(0).getIsRedundantRouter())) {
+            try {
+                Thread.sleep(10000L);
+            } catch (final InterruptedException ignored) {}
+        }
+
+        // Destroy old routers
+        for (final DomainRouterVO oldRouter : oldRouters) {
+            _routerService.destroyRouter(oldRouter.getId(), 
context.getAccount(), context.getCaller().getId());
 
 Review comment:
   Here, before validating the new routers, we are destroying the old ones. If 
the new routers don't come up properly, we won't have old routers to roll back.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> restartnetwork with cleanup should not update/restart both routers at once
> --------------------------------------------------------------------------
>
>                 Key: CLOUDSTACK-9114
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9114
>             Project: CloudStack
>          Issue Type: Improvement
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>            Reporter: Wei Zhou
>            Assignee: Wei Zhou
>            Priority: Major
>
> for now, restartnetwork with cleanup will stop both RVRs at first, then start 
> two  new RVRs.
> to reduce the downtime of network, we'd better restart the RVRs one by one.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to