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_r358158692
 
 

 ##########
 File path: 
server/src/main/java/com/cloud/network/router/VirtualNetworkApplianceManagerImpl.java
 ##########
 @@ -1186,6 +1227,431 @@ protected void pushToUpdateQueue(final List<NetworkVO> 
networks) throws Interrup
         }
     }
 
+    protected class FetchRouterHealthChecksResultTask extends 
ManagedContextRunnable {
+        public FetchRouterHealthChecksResultTask() {
+        }
+
+        @Override
+        protected void runInContext() {
+            try {
+                final List<DomainRouterVO> routers = 
_routerDao.listByStateAndManagementServer(VirtualMachine.State.Running, 
mgmtSrvrId);
+                s_logger.debug("Found " + routers.size() + " running routers. 
");
+
+                for (final DomainRouterVO router : routers) {
+                    GetRouterMonitorResultsAnswer answer = 
fetchAndUpdateRouterHealthChecks(router, false);
+                    String checkFailsToRestartVr = 
RouterHealthChecksFailuresToRestartVr.valueIn(router.getDataCenterId());
+                    if (answer == null) {
+                        s_logger.warn("Unable to fetch monitor results for 
router " + router);
+                        updateRouterConnectivityHealthCheck(router.getId(), 
false, "Communication failed");
+                    } else if (!answer.getResult()) {
+                        s_logger.warn("Failed to fetch monitor results from 
router " + router + " with details: " + answer.getDetails());
+                        updateRouterConnectivityHealthCheck(router.getId(), 
false, "Failed to fetch results with details: " + answer.getDetails());
+                    } else {
+                        updateRouterConnectivityHealthCheck(router.getId(), 
true, "Successfully fetched data");
+                        parseAndMergeDbHealthChecks(router.getId(), 
answer.getMonitoringResults());
+
+                        // Check failing tests and restart if needed
+                        if (answer.getFailingChecks().size() > 0 && 
StringUtils.isNotBlank(checkFailsToRestartVr)) {
+                            s_logger.info("Checking failed health checks to 
see if router needs reboot");
+                            for (String failedCheck : 
answer.getFailingChecks()) {
+                                if 
(checkFailsToRestartVr.contains(failedCheck)) {
+                                    s_logger.info("Found failing health check 
" + failedCheck + " so restarting router.");
 
 Review comment:
   isn't this a warning instead of info? we are rebooting a customer network 
here!

----------------------------------------------------------------
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