Gilad Chaplik has uploaded a new change for review.

Change subject: core: positive affinity breaks maintenancing a host
......................................................................

core: positive affinity breaks maintenancing a host

I feel that this is best to describe with an example: vm1, vm2 running
with enforcing positive affinity group on host A.
When putting host A to maintenance, both VMs will try to migrate,
and fail because they're violating the affinity constraints.
the host is stuck on preparing for maint.

The fix ignores the host when it's in preparing for maint status.

Change-Id: I7282a9e1c87b30c14869170ed7fb5b9276fad33e
Bug-Url: https://bugzilla.redhat.com/1084794
Signed-off-by: Gilad Chaplik <gchap...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/VmAffinityFilterPolicyUnit.java
1 file changed, 9 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/23/26623/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/VmAffinityFilterPolicyUnit.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/VmAffinityFilterPolicyUnit.java
index ef216bf..904c57f 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/VmAffinityFilterPolicyUnit.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/VmAffinityFilterPolicyUnit.java
@@ -11,6 +11,7 @@
 import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.bll.scheduling.PolicyUnitImpl;
 import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.scheduling.AffinityGroup;
@@ -73,18 +74,21 @@
         for (VM iter : getVmDao().getAllRunningByCluster(vm.getVdsGroupId())) {
             runningVMsMap.put(iter.getId(), iter);
         }
+        Map<Guid, VDS> hostMap = new HashMap<>();
+        for (VDS host : hosts) {
+            hostMap.put(host.getId(), host);
+        }
 
         Set<Guid> acceptableHosts = new HashSet<Guid>();
         // Group all hosts for VMs with positive affinity
         for (Guid id : allVmIdsPositive) {
             VM runVm = runningVMsMap.get(id);
-            if (runVm != null && runVm.getRunOnVds() != null) {
+            if (runVm != null && runVm.getRunOnVds() != null && 
hostMap.get(runVm.getRunOnVds()) != null
+                    // when a host preparing for maintenance, we should ignore 
the positive affinity (without that we
+                    // can't migrate).
+                    && hostMap.get(runVm.getRunOnVds()).getStatus() != 
VDSStatus.PreparingForMaintenance) {
                 acceptableHosts.add(runVm.getRunOnVds());
             }
-        }
-        Map<Guid, VDS> hostMap = new HashMap<>();
-        for (VDS host : hosts) {
-            hostMap.put(host.getId(), host);
         }
         boolean hasPositiveConstraint = false;
         // No hosts associated with positive affinity, all hosts is applicable.


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

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

Reply via email to