Gilad Chaplik has uploaded a new change for review.

Change subject: core: scheduling: remove migration domain filter
......................................................................

core: scheduling: remove migration domain filter

Currently there is on way to migrate a vm between clusters, therefore
migration domain filter is causing a problem when it's not enabled.
This patch removes the filter, and added it's logic (up state and same cluster)
to the initial host list provided to the filters.

This patch also includes that balancing initial hosts list to be hosts
without migrating vms to allow backward compatability.

Change-Id: I5aea1d3d1e5e63f03ab0d012d4d3fe9356f26e48
Bug-Url: https://bugzilla.redhat.com/988306
Signed-off-by: Gilad Chaplik <gchap...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/EvenDistributionBalancePolicyUnit.java
D 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/MigrationDomainPolicyUnit.java
A packaging/dbscripts/upgrade/03_03_0770_remove_migration_domain_filter.sql
5 files changed, 17 insertions(+), 55 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/69/18069/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java
index 31734d3..db6ae79 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/PolicyUnitImpl.java
@@ -9,7 +9,6 @@
 import 
org.ovirt.engine.core.bll.scheduling.policyunits.EvenDistributionBalancePolicyUnit;
 import 
org.ovirt.engine.core.bll.scheduling.policyunits.EvenDistributionWeightPolicyUnit;
 import org.ovirt.engine.core.bll.scheduling.policyunits.MemoryPolicyUnit;
-import 
org.ovirt.engine.core.bll.scheduling.policyunits.MigrationDomainPolicyUnit;
 import org.ovirt.engine.core.bll.scheduling.policyunits.MigrationPolicyUnit;
 import org.ovirt.engine.core.bll.scheduling.policyunits.NetworkPolicyUnit;
 import org.ovirt.engine.core.bll.scheduling.policyunits.NoneBalancePolicyUnit;
@@ -36,8 +35,6 @@
         switch (policyUnit.getName()) {
         case "Migration":
             return new MigrationPolicyUnit(policyUnit);
-        case "MigrationDomain":
-            return new MigrationDomainPolicyUnit(policyUnit);
         case "PinToHost":
             return new PinToHostPolicyUnit(policyUnit);
         case "CPU":
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
index eddf180..fc6695c 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
@@ -19,7 +19,7 @@
 import org.ovirt.engine.core.common.businessentities.MigrationSupport;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
-import org.ovirt.engine.core.common.businessentities.VDSType;
+import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.config.Config;
 import org.ovirt.engine.core.common.config.ConfigValues;
@@ -173,7 +173,7 @@
         clusterLockMap.putIfAbsent(cluster.getId(), new Object());
         synchronized (clusterLockMap.get(cluster.getId())) {
             List<VDS> vdsList = getVdsDAO()
-                    .getAllOfTypes(new VDSType[] { VDSType.VDS, 
VDSType.oVirtNode });
+                    .getAllForVdsGroupWithStatus(cluster.getId(), 
VDSStatus.Up);
             updateInitialHostList(vdsList, hostBlackList, true);
             updateInitialHostList(vdsList, hostWhiteList, false);
             ClusterPolicy policy = policyMap.get(cluster.getClusterPolicyId());
@@ -227,7 +227,7 @@
             Guid destVdsId,
             List<String> messages) {
         List<VDS> vdsList = getVdsDAO()
-                .getAllOfTypes(new VDSType[] { VDSType.VDS, VDSType.oVirtNode 
});
+                .getAllForVdsGroupWithStatus(cluster.getId(), VDSStatus.Up);
         updateInitialHostList(vdsList, vdsBlackList, true);
         updateInitialHostList(vdsList, vdsWhiteList, false);
         ClusterPolicy policy = policyMap.get(cluster.getClusterPolicyId());
@@ -596,11 +596,12 @@
             ClusterPolicy policy = policyMap.get(cluster.getClusterPolicyId());
             PolicyUnitImpl policyUnit = policyUnits.get(policy.getBalance());
             Pair<List<Guid>, Guid> balanceResult = null;
-            if (policyUnit.isInternal()){
-                balanceResult = internalRunBalance(policyUnit, cluster);
-            } else if (Config.GetValue(ConfigValues.ExternalSchedulerEnabled)) 
{
-                if (policyUnit.isEnabled()) {
-                    balanceResult = externalRunBalance(policyUnit, cluster);
+            if (policyUnit.isEnabled()) {
+                List<VDS> hosts = 
getVdsDAO().getAllForVdsGroupWithoutMigrating(cluster.getId());
+                if (policyUnit.isInternal()) {
+                    balanceResult = internalRunBalance(policyUnit, cluster, 
hosts);
+                } else if 
(Config.GetValue(ConfigValues.ExternalSchedulerEnabled)) {
+                    balanceResult = externalRunBalance(policyUnit, cluster, 
hosts);
                 }
             }
 
@@ -610,18 +611,14 @@
         }
     }
 
-    private Pair<List<Guid>, Guid> internalRunBalance(PolicyUnitImpl 
policyUnit, VDSGroup cluster) {
-        List<VDS> hosts = getVdsDAO()
-                .getAllOfTypes(new VDSType[] { VDSType.VDS, VDSType.oVirtNode 
});
+    private Pair<List<Guid>, Guid> internalRunBalance(PolicyUnitImpl 
policyUnit, VDSGroup cluster, List<VDS> hosts) {
         return policyUnit.balance(cluster,
                 hosts,
                 cluster.getClusterPolicyProperties(),
                 new ArrayList<String>());
     }
 
-    private Pair<List<Guid>, Guid> externalRunBalance(PolicyUnitImpl 
policyUnit, VDSGroup cluster){
-        List<VDS> hosts = getVdsDAO()
-                .getAllOfTypes(new VDSType[] { VDSType.VDS, VDSType.oVirtNode 
});
+    private Pair<List<Guid>, Guid> externalRunBalance(PolicyUnitImpl 
policyUnit, VDSGroup cluster, List<VDS> hosts) {
         List<Guid> hostIDs = new ArrayList<Guid>();
         for (VDS vds : hosts) {
             hostIDs.add(vds.getId());
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/EvenDistributionBalancePolicyUnit.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/EvenDistributionBalancePolicyUnit.java
index ad5922b..6adaa81 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/EvenDistributionBalancePolicyUnit.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/EvenDistributionBalancePolicyUnit.java
@@ -38,19 +38,18 @@
             List<VDS> hosts,
             Map<String, String> parameters,
             ArrayList<String> messages) {
-        List<VDS> relevantHosts = 
getVdsDao().getAllForVdsGroupWithoutMigrating(cluster.getId());
-        if (relevantHosts == null || relevantHosts.size() < 2) {
-            int hostCount = relevantHosts == null ? 0 : relevantHosts.size();
+        if (hosts == null || hosts.size() < 2) {
+            int hostCount = hosts == null ? 0 : hosts.size();
             log.debugFormat("No balancing for cluster {0}, contains only {1} 
host(s)", cluster.getName(), hostCount);
             return null;
         }
         // get vds that over committed for the time defined
-        List<VDS> overUtilizedHosts = getOverUtilizedHosts(relevantHosts, 
parameters);
+        List<VDS> overUtilizedHosts = getOverUtilizedHosts(hosts, parameters);
 
         if (overUtilizedHosts == null || overUtilizedHosts.size() == 0) {
             return null;
         }
-        List<VDS> underUtilizedHosts = getUnderUtilizedHosts(cluster, 
relevantHosts, parameters);
+        List<VDS> underUtilizedHosts = getUnderUtilizedHosts(cluster, hosts, 
parameters);
         if (underUtilizedHosts == null || underUtilizedHosts.size() == 0) {
             return null;
         }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/MigrationDomainPolicyUnit.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/MigrationDomainPolicyUnit.java
deleted file mode 100644
index 1c26c62..0000000
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/policyunits/MigrationDomainPolicyUnit.java
+++ /dev/null
@@ -1,33 +0,0 @@
-package org.ovirt.engine.core.bll.scheduling.policyunits;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-
-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.PolicyUnit;
-
-public class MigrationDomainPolicyUnit extends PolicyUnitImpl {
-
-    public MigrationDomainPolicyUnit(PolicyUnit policyUnit) {
-        super(policyUnit);
-    }
-
-    @Override
-    public List<VDS> filter(List<VDS> hosts, VM vm, Map<String, String> 
parameters, List<String> messages) {
-        List<VDS> toRemoveHostList = new ArrayList<VDS>();
-        for (VDS host : hosts) {
-            if ((!host.getVdsGroupId().equals(vm.getVdsGroupId())) || 
(host.getStatus() != VDSStatus.Up)) {
-                log.debugFormat("host: {0} is not in up status or belongs to 
the VM's cluster", host.getName());
-                
messages.add(VdcBllMessages.ACTION_TYPE_FAILED_VDS_VM_CLUSTER.toString());
-                toRemoveHostList.add(host);
-            }
-        }
-        hosts.removeAll(toRemoveHostList);
-        return hosts;
-    }
-}
diff --git 
a/packaging/dbscripts/upgrade/03_03_0770_remove_migration_domain_filter.sql 
b/packaging/dbscripts/upgrade/03_03_0770_remove_migration_domain_filter.sql
new file mode 100644
index 0000000..a9ec8d2
--- /dev/null
+++ b/packaging/dbscripts/upgrade/03_03_0770_remove_migration_domain_filter.sql
@@ -0,0 +1,2 @@
+-- initial host list will be up hosts from the VM's cluster
+DELETE FROM policy_units WHERE id = 'a267eddb-768d-45fd-9dbb-6ebcee343508';


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I5aea1d3d1e5e63f03ab0d012d4d3fe9356f26e48
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