You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/05/06 13:45:19 UTC

[GitHub] [cloudstack] GabrielBrascher commented on a change in pull request #4978: KVM High Availability regardless of storage

GabrielBrascher commented on a change in pull request #4978:
URL: https://github.com/apache/cloudstack/pull/4978#discussion_r627433177



##########
File path: plugins/hypervisors/kvm/src/main/java/com/cloud/ha/KVMInvestigator.java
##########
@@ -85,12 +89,35 @@ public Status isAgentAlive(Host agent) {
                 break;
             }
         }
-        if (!hasNfs) {
-            s_logger.warn(
-                    "Agent investigation was requested on host " + agent + ", but host does not support investigation because it has no NFS storage. Skipping investigation.");
-            return Status.Disconnected;
+        Status agentStatus = Status.Disconnected;
+        if (hasNfs) {
+            agentStatus = checkAgentStatusViaNfs(agent);
+            s_logger.debug(String.format("Agent investigation was requested on host %s. Agent status via NFS heartbeat is %s.", agent, agentStatus));
+        } else {
+            s_logger.debug(String.format("Agent investigation was requested on host %s, but host has no NFS storage. Skipping investigation via NFS.", agent));
         }
 
+        agentStatus = checkAgentStatusViaKvmHaAgent(agent, agentStatus);
+
+        return agentStatus;
+    }
+
+    /**
+     * It checks the KVM node healthy via KVM HA Agent. If the agent is healthy it returns Status.Up, otherwise it keeps the provided Status as it is.
+     */
+    private Status checkAgentStatusViaKvmHaAgent(Host agent, Status agentStatus) {
+        KvmHaAgentClient kvmHaAgentClient = new KvmHaAgentClient(agent);
+        boolean isVmsCountOnKvmMatchingWithDatabase = kvmHaAgentClient.isKvmHaAgentHealthy(agent, vmInstanceDao);
+        if(isVmsCountOnKvmMatchingWithDatabase) {
+            agentStatus = Status.Up;
+            s_logger.debug(String.format("Checking agent %s status; KVM HA Agent is Running as expected."));
+        } else {
+            s_logger.warn(String.format("Checking agent %s status. Failed to check host status via KVM HA Agent"));

Review comment:
       Code has been updated adrressing these `String.format` missing parameters. Thanks @wido!

##########
File path: plugins/hypervisors/kvm/src/main/java/com/cloud/ha/KVMInvestigator.java
##########
@@ -85,12 +89,35 @@ public Status isAgentAlive(Host agent) {
                 break;
             }
         }
-        if (!hasNfs) {
-            s_logger.warn(
-                    "Agent investigation was requested on host " + agent + ", but host does not support investigation because it has no NFS storage. Skipping investigation.");
-            return Status.Disconnected;
+        Status agentStatus = Status.Disconnected;
+        if (hasNfs) {
+            agentStatus = checkAgentStatusViaNfs(agent);
+            s_logger.debug(String.format("Agent investigation was requested on host %s. Agent status via NFS heartbeat is %s.", agent, agentStatus));
+        } else {
+            s_logger.debug(String.format("Agent investigation was requested on host %s, but host has no NFS storage. Skipping investigation via NFS.", agent));
         }
 
+        agentStatus = checkAgentStatusViaKvmHaAgent(agent, agentStatus);
+
+        return agentStatus;
+    }
+
+    /**
+     * It checks the KVM node healthy via KVM HA Agent. If the agent is healthy it returns Status.Up, otherwise it keeps the provided Status as it is.
+     */
+    private Status checkAgentStatusViaKvmHaAgent(Host agent, Status agentStatus) {
+        KvmHaAgentClient kvmHaAgentClient = new KvmHaAgentClient(agent);
+        boolean isVmsCountOnKvmMatchingWithDatabase = kvmHaAgentClient.isKvmHaAgentHealthy(agent, vmInstanceDao);
+        if(isVmsCountOnKvmMatchingWithDatabase) {
+            agentStatus = Status.Up;
+            s_logger.debug(String.format("Checking agent %s status; KVM HA Agent is Running as expected."));
+        } else {
+            s_logger.warn(String.format("Checking agent %s status. Failed to check host status via KVM HA Agent"));

Review comment:
       Code has been updated adressing these `String.format` missing parameters. Thanks @wido!




-- 
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:
users@infra.apache.org