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> (cherry picked from commit cb27efb5b9561420da8ecb7c44a3b4013c126acb) --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/VmAffinityFilterPolicyUnit.java 1 file changed, 9 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/89/32889/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 5b2851e..79f7952 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 @@ -9,6 +9,7 @@ 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; @@ -70,12 +71,19 @@ 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<>(); // 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()); } } @@ -87,11 +95,6 @@ if (runVm != null && runVm.getRunOnVds() != null) { unacceptableHosts.add(runVm.getRunOnVds()); } - } - - Map<Guid, VDS> hostMap = new HashMap<>(); - for (VDS host : hosts) { - hostMap.put(host.getId(), host); } // Compute the intersection of hosts with positive and negative affinity and report that -- To view, visit http://gerrit.ovirt.org/32889 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I7282a9e1c87b30c14869170ed7fb5b9276fad33e Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: ovirt-engine-3.5 Gerrit-Owner: Gilad Chaplik <gchap...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches