Roy Golan has uploaded a new change for review.

Change subject: core: log mismatches of the VdsSelector (#855776)
......................................................................

core: log mismatches of the VdsSelector (#855776)

http://bugzilla.redhat.com/855776

when the VdsSelector fails to find a VDS to run a VM on a debug log
message will be printed with all the mismatches.

Change-Id: I0ce7fc97734f2bd2444a067e995563d36262ff43
Signed-off-by: Roy Golan <rgo...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java
1 file changed, 48 insertions(+), 9 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/13/7913/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java
index 3cc8567..87e79c4 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsSelector.java
@@ -5,6 +5,7 @@
 import java.util.List;
 
 import org.apache.commons.lang.StringUtils;
+import org.ovirt.engine.core.common.businessentities.Entities;
 import org.ovirt.engine.core.common.businessentities.MigrationSupport;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
@@ -289,42 +290,80 @@
     }
 
     private Guid getVdsToRunOn(Iterable<VDS> vdss) {
+        // buffer info on mismatches as we go with
+        StringBuilder sb = new StringBuilder();
+
         final List<VDS> readyToRun = new ArrayList<VDS>();
         for (VDS curVds : vdss) {
+            sb.append("\n VDS ").append(curVds.getvds_name()).append(" 
").append(curVds.getId()).append(" ");
             // vds must be in the correct group
-            if (!curVds.getvds_group_id().equals(getVm().getvds_group_id()))
+            if (!curVds.getvds_group_id().equals(getVm().getvds_group_id())) {
+                sb.append("is not a member of cluster 
").append(getVm().getvds_group_name());
                 continue;
-
+            }
             // vds must be up to run a vm
-            if (curVds.getstatus() != VDSStatus.Up)
+            if (curVds.getstatus() != VDSStatus.Up) {
+                sb.append("is not in status UP");
                 continue;
+            }
 
             // apply limit on vds memory over commit.
-            if (!RunVmCommandBase.hasMemoryToRunVM(curVds, getVm()))
+            if (!RunVmCommandBase.hasMemoryToRunVM(curVds, getVm())) {
+                sb.append("doesn't have enough memory run the VM");
                 continue;
+            }
 
             // In case we are using this function in migration we make sure we
             // don't allocate the same VDS
             if ((getVm().getrun_on_vds() != null && 
getVm().getrun_on_vds().equals(curVds.getId()))
                     || isVdsFailedToRunVm(curVds.getId()) ||
                     // RunVmCommandBase.isVdsVersionOld(curVds, getVm()) ||
-                    !RunVmCommandBase.hasCapacityToRunVM(curVds))
+                    !RunVmCommandBase.hasCapacityToRunVM(curVds)) {
+                sb.append("is the same vds the VM migrating from");
                 continue;
+            }
 
             // vds must have at least cores as the vm
             if (curVds.getcpu_cores() != null && getVm().getnum_of_cpus() > 
curVds.getcpu_cores()) {
+                appendCoresInfo(sb, curVds);
                 continue;
             }
-            if (!IsVMSwapValueLegal(curVds))
+            if (!IsVMSwapValueLegal(curVds)) {
+                appendSwapInfo(sb, curVds);
                 continue;
-
-            if(!areRequiredNetworksAvailable(curVds.getId()))
+            }
+            if(!areRequiredNetworksAvailable(curVds.getId())) {
+                sb.append("is missing one or more of networks needed by the VM 
interfaces network's 
").append(Entities.interfacesByNetworkName(getVmNICs()).keySet());
                 continue;
+            }
 
             readyToRun.add(curVds);
         }
 
-        return readyToRun.isEmpty() ? Guid.Empty : getBestVdsToRun(readyToRun);
+        if (readyToRun.isEmpty()) {
+            if (log.isDebugEnabled()) {
+                log.debug(sb.toString());
+            }
+            return Guid.Empty;
+        } else {
+            return getBestVdsToRun(readyToRun);
+        }
+    }
+
+    private void appendSwapInfo(StringBuilder sb, VDS curVds) {
+        sb.append("has illegal swap value. |swap total|swap free|available 
mem|physical mem| : ")
+                .append(curVds.getswap_free()).append("|")
+                .append(curVds.getswap_total()).append("|")
+                .append(curVds.getmem_available()).append("|")
+                .append(curVds.getphysical_mem_mb()).append("|");
+    }
+
+    private void appendCoresInfo(StringBuilder sb, VDS curVds) {
+        sb.append("is having less cores(")
+                .append(curVds.getcpu_cores())
+                .append(") than the VM(")
+                .append(getVm().getnum_of_cpus())
+                .append(")");
     }
 
     /**


--
To view, visit http://gerrit.ovirt.org/7913
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0ce7fc97734f2bd2444a067e995563d36262ff43
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Roy Golan <rgo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to