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



##########
File path: 
plugins/hypervisors/kvm/src/main/java/org/apache/cloudstack/kvm/ha/KVMHostActivityChecker.java
##########
@@ -59,29 +68,63 @@
     @Inject
     private AgentManager agentMgr;
     @Inject
-    private PrimaryDataStoreDao storagePool;
-    @Inject
     private StorageManager storageManager;
     @Inject
+    private PrimaryDataStoreDao storagePool;
+    @Inject
     private ResourceManager resourceManager;
+    @Inject
+    private StoragePoolHostDao storagePoolHostDao;
+    @Inject
+    private KvmHaHelper kvmHaHelper;
+
+    private static final Set<Storage.StoragePoolType> NFS_POOL_TYPE = new 
HashSet<>(Arrays.asList(Storage.StoragePoolType.NetworkFilesystem, 
Storage.StoragePoolType.ManagedNFS));
+    private static final Set<Hypervisor.HypervisorType> KVM_OR_LXC = new 
HashSet<>(Arrays.asList(Hypervisor.HypervisorType.KVM, 
Hypervisor.HypervisorType.LXC));
 
     @Override
-    public boolean isActive(Host r, DateTime suspectTime) throws 
HACheckerException {
+    public boolean isActive(Host host, DateTime suspectTime) throws 
HACheckerException {
         try {
-            return isVMActivtyOnHost(r, suspectTime);
+            return isVMActivtyOnHost(host, suspectTime);
         } catch (HACheckerException e) {
             //Re-throwing the exception to avoid poluting the 
'HACheckerException' already thrown
             throw e;
-        } catch (Exception e){
-            String message = String.format("Operation timed out, probably the 
%s is not reachable.", r.toString());
+        } catch (Exception e) {
+            String message = String.format("Operation timed out, probably the 
%s is not reachable.", host.toString());
             LOG.warn(message, e);
             throw new HACheckerException(message, e);
         }
     }
 
     @Override
-    public boolean isHealthy(Host r) {
-        return isAgentActive(r);
+    public boolean isHealthy(Host host) {
+        boolean isHealthy = true;
+        boolean isHostServedByNfsPool = isHostServedByNfsPool(host);
+        boolean isKvmHaWebserviceEnabled = 
kvmHaHelper.isKvmHaWebserviceEnabled(host);
+
+        if (isHostServedByNfsPool) {
+            isHealthy = isHealthViaNfs(host);
+        }
+
+        if (!isKvmHaWebserviceEnabled) {
+            return isHealthy;
+        }
+
+        if (kvmHaHelper.isKvmHealthyCheckViaLibvirt(host) && !isHealthy) {
+            return true;
+        }
+
+        return isHealthy;
+    }
+
+    private boolean isHealthViaNfs(Host r) {
+        boolean isHealthy = true;
+        if (isHostServedByNfsPool(r)) {
+            isHealthy = isAgentActive(r);
+            if (!isHealthy) {
+                LOG.warn(String.format("NFS storage health check failed for 
%s. It seems that a storage does not have activity.", r.toString()));
+            }
+        }

Review comment:
       Nice! I like the idea @GutoVeronezi, I will enhance this part and ensure 
to cover the flows with some relevant logs.




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