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



##########
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."));

Review comment:
       Shouldn't we pass an argument for '%s'?
   
   Right now this won't print something properly.

##########
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:
       Shouldn't we pass an argument for '%s'?
   
   Right now this won't print something properly.




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


Reply via email to