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_r358144424
##########
File path:
core/src/main/java/com/cloud/agent/resource/virtualnetwork/VirtualRoutingResource.java
##########
@@ -268,6 +267,49 @@ private CheckS2SVpnConnectionsAnswer
execute(CheckS2SVpnConnectionsCommand cmd)
return new CheckS2SVpnConnectionsAnswer(cmd, result.isSuccess(),
result.getDetails());
}
+ private GetRouterMonitorResultsAnswer
execute(GetRouterMonitorResultsCommand cmd) {
+ String routerIp = cmd.getAccessDetail(NetworkElementCommand.ROUTER_IP);
+ String args = cmd.shouldPerformFreshChecks() ? "true" : "false";
+ s_logger.debug("Fetching health check result for " + routerIp + " and
executing fresh checks: " + args);
+ ExecutionResult result = _vrDeployer.executeInVR(routerIp,
VRScripts.ROUTER_MONITOR_RESULTS, args);
+
+ if (!result.isSuccess()) {
+ s_logger.warn("Result of " + cmd + " failed with details: " +
result.getDetails());
+ return new GetRouterMonitorResultsAnswer(cmd, false, null,
result.getDetails());
+ }
+
+ if (result.getDetails().isEmpty()) {
+ s_logger.warn("Result of " + cmd + " received no details.");
+ return new GetRouterMonitorResultsAnswer(cmd, false, null, "No
results available.");
+ }
+
+ List<String> failingChecks = new ArrayList<>();
+ StringBuilder monitorResults = new StringBuilder();
+ String[] lines = result.getDetails().trim().split("\n");
+ boolean readingFailedChecks = false, readingMonitorResults = false;
+ for (String line : lines) {
+ line = line.trim();
+ if (line.contains("FAILING CHECKS")) {
+ readingFailedChecks = true;
+ readingMonitorResults = false;
+ } else if (line.contains("MONITOR RESULTS")) {
+ readingFailedChecks = false;
+ readingMonitorResults = true;
+ } else if (readingFailedChecks && !readingMonitorResults) {
+ for (String w : line.split(",")) {
+ if (!w.trim().isEmpty()) {
+ failingChecks.add(w.trim());
+ }
+ }
Review comment:
so a nested parser...? or just lexing the errors? factoring this out with a
descriptive method name would make it more readable.
----------------------------------------------------------------
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