DaanHoogland commented on a change in pull request #3575: [WIP DO NOT MERGE] 
Health check feature for virtual router
URL: https://github.com/apache/cloudstack/pull/3575#discussion_r365999398
 
 

 ##########
 File path: 
server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
 ##########
 @@ -1271,6 +1280,43 @@ protected void runInContext() {
         }
     }
 
+    /**
+     * Attempts recreation of router by restarting with cleanup a VPC if any 
or a guest network associated in case no VPC.
+     * @param routerId - the id of the router to be recreated.
+     * @return true if successfully restart is attempted else false.
+     */
+    private boolean recreateRouter(long routerId) {
+        List<DomainRouterJoinVO> routerJoinVOs = 
domainRouterJoinDao.searchByIds(routerId);
+        DomainRouterJoinVO routerJoinToRestart = null;
+        User systemUser = _userDao.getUser(User.UID_SYSTEM);
+        for (DomainRouterJoinVO router : routerJoinVOs) {
+            if (router.getRemoved() == null && router.getTrafficType() == 
TrafficType.Guest) {
+                if (router.getVpcId() != 0) {
+                    try {
+                        s_logger.debug("Attempting restart VPC " + 
router.getVpcName() + " for router recreation " + router.getUuid());
+                        return vpcService.restartVpc(router.getVpcId(), true, 
false, systemUser);
+                    } catch (Exception e) {
+                        s_logger.error("Failed to restart VPC for router 
recreation " + router.getVpcName() + " ,router " + router.getUuid(), e);
+                    }
+                }
+                routerJoinToRestart = router;
+            }
 
 Review comment:
   Yes, it makes sense but it is ugly, and I wonder how maintainable it is.
   Is it even possible that one router has a vpc and another doesn't?
   So, if we found one without vpc id can we also not stop querying the rest 
and just restart?

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


With regards,
Apache Git Services

Reply via email to