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 2020/01/07 09:41:27 UTC

[GitHub] [cloudstack] DaanHoogland commented on a change in pull request #3795: Agent lb on svm

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

 ##########
 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:
   refactorred have a look, @rhtyd . I think it is cosmetic but it does make a point.

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


With regards,
Apache Git Services