rhtyd commented on a change in pull request #3795: Agent lb on svm
URL: https://github.com/apache/cloudstack/pull/3795#discussion_r363611934
 
 

 ##########
 File path: 
server/src/main/java/org/apache/cloudstack/agent/lb/IndirectAgentLBServiceImpl.java
 ##########
 @@ -136,17 +144,48 @@ public int compare(Long x, Long y) {
         }
         final List <Host> agentBasedHosts = new ArrayList<>();
         for (final Host host : allHosts) {
-            if (host == null || host.getResourceState() == 
ResourceState.Creating || host.getResourceState() == ResourceState.Error) {
-                continue;
+            conditionallyAddHost(agentBasedHosts, host);
+        }
+        return agentBasedHosts;
+    }
+
+    private void conditionallyAddHost(List<Host> agentBasedHosts, Host host) {
+        if (host == null) {
+            if (LOG.isTraceEnabled()) {
+                LOG.trace("trying to add no host to a list");
             }
-            if (host.getType() == Host.Type.Routing || host.getType() == 
Host.Type.ConsoleProxy || host.getType() == Host.Type.SecondaryStorage || 
host.getType() == Host.Type.SecondaryStorageVM) {
-                if (host.getHypervisorType() != null && 
host.getHypervisorType() != Hypervisor.HypervisorType.KVM && 
host.getHypervisorType() != Hypervisor.HypervisorType.LXC) {
-                    continue;
-                }
-                agentBasedHosts.add(host);
+            return;
+        }
+        if (host.getResourceState() == ResourceState.Creating) {
+            if (LOG.isTraceEnabled()) {
+                LOG.trace(String.format("host is in creating state, not adding 
to the host list, (id = %s)", host.getUuid()));
             }
+            return;
         }
-        return agentBasedHosts;
+        if (host.getResourceState() == ResourceState.Error) {
 
 Review comment:
   oh I see it's already here, we could probably do something like `item in 
array` where array is list of unsupported states?

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