Martin Sivák has uploaded a new change for review.

Change subject: core: Use pin to host only when present in cluster policy
......................................................................

core: Use pin to host only when present in cluster policy

This removes the explicit pin to host check in scheduling.
The check is already present in cluster policy and will be used
when the policy unit is selected by the administrator.

It also restores the optimization we had in the code that
used Pin To Host logic as the first filter for the provided
cluster policies.

Change-Id: If2c0496327c9f692b0dbe92e1cf481f900f4a747
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1007282
Signed-off-by: Martin Sivak <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/scheduling/SchedulingManager.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
A 
packaging/dbscripts/upgrade/03_03_0990_pin_to_host_first_in_powersaving_policy.sql
3 files changed, 17 insertions(+), 54 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/53/20153/1

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 09a3c71..a3a01a9 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
@@ -16,7 +16,6 @@
 import 
org.ovirt.engine.core.bll.scheduling.external.ExternalSchedulerDiscoveryThread;
 import org.ovirt.engine.core.bll.scheduling.external.ExternalSchedulerFactory;
 import org.ovirt.engine.core.common.businessentities.BusinessEntity;
-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.VDSStatus;
@@ -179,19 +178,7 @@
             updateInitialHostList(vdsList, hostWhiteList, false);
             ClusterPolicy policy = policyMap.get(cluster.getClusterPolicyId());
             Map<String, String> parameters = 
createClusterPolicyParameters(cluster);
-            if (destHostId != null) {
-                if (checkDestinationHost(vm,
-                        vdsList,
-                        destHostId,
-                        messages,
-                        policy,
-                        parameters,
-                        memoryChecker)) {
-                    return destHostId;
-                } else if (vm.getMigrationSupport() == 
MigrationSupport.PINNED_TO_HOST) {
-                    return null;
-                }
-            }
+
             vdsList =
                     runFilters(policy.getFilters(),
                             vdsList,
@@ -203,6 +190,18 @@
 
             if (vdsList == null || vdsList.size() == 0) {
                 return null;
+            }
+            // If a default destination host was specified and made it
+            // through all filters -> use it
+            if (vdsList != null) {
+                for (VDS vds: vdsList) {
+                    if (vds.getId().equals(destHostId)) {
+                        return destHostId;
+                    }
+                }
+            }
+            if (vdsList != null && vdsList.contains(destHostId)) {
+                return destHostId;
             }
             if (policy.getFunctions() == null || 
policy.getFunctions().isEmpty()) {
                 return vdsList.get(0).getId();
@@ -233,19 +232,7 @@
         updateInitialHostList(vdsList, vdsWhiteList, false);
         ClusterPolicy policy = policyMap.get(cluster.getClusterPolicyId());
         Map<String, String> parameters = 
createClusterPolicyParameters(cluster);
-        if (destVdsId != null) {
-            if (checkDestinationHost(vm,
-                    vdsList,
-                    destVdsId,
-                    messages,
-                    policy,
-                    parameters,
-                    noWaitingMemoryChecker)) {
-                return true;
-            } else if (vm.getMigrationSupport() == 
MigrationSupport.PINNED_TO_HOST) {
-                return false;
-            }
-        }
+
         vdsList =
                 runFilters(policy.getFilters(),
                         vdsList,
@@ -259,32 +246,6 @@
             return false;
         }
         return true;
-    }
-
-    protected boolean checkDestinationHost(VM vm,
-            List<VDS> vdsList,
-            Guid destVdsId,
-            List<String> messages,
-            ClusterPolicy policy,
-            Map<String, String> parameters,
-            VdsFreeMemoryChecker memoryChecker) {
-        List<VDS> destVdsList = new ArrayList<VDS>();
-        for (VDS vds : vdsList) {
-            if (vds.getId().equals(destVdsId)) {
-                destVdsList.add(vds);
-                break;
-            }
-        }
-        destVdsList =
-                runFilters(policy.getFilters(),
-                        destVdsList,
-                        vm,
-                        parameters,
-                        policy.getFilterPositionMap(),
-                        messages,
-                        memoryChecker);
-
-        return destVdsList != null && destVdsList.size() == 1;
     }
 
     static List<Guid> getEntityIds(List<? extends BusinessEntity<Guid>> 
entities) {
diff --git 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
index c798e07..67439c7 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -166,7 +166,7 @@
 USER_RESUME_VM=VM ${VmName} was resumed by ${UserName} (Host: ${VdsName}).
 USER_RUN_VM=VM ${VmName} started on Host ${VdsName}
 USER_RUN_VM_AS_STATELESS=VM ${VmName} started on Host ${VdsName} as stateless
-USER_RUN_VM_ON_NON_DEFAULT_VDS=Guest ${VmName} started on Host ${VdsName}. 
(Default Host parameter was ignored - assigned Host was down).
+USER_RUN_VM_ON_NON_DEFAULT_VDS=Guest ${VmName} started on Host ${VdsName}. 
(Default Host parameter was ignored - assigned Host was not available).
 USER_STOP_VM=VM ${VmName} powered off by ${UserName} (Host: ${VdsName}).
 USER_STOP_SUSPENDED_VM=Suspended VM ${VmName} powered off by ${UserName}.
 USER_STOP_SUSPENDED_VM_FAILED=Failed to power off suspended VM ${VmName} 
(User: ${UserName}).
diff --git 
a/packaging/dbscripts/upgrade/03_03_0990_pin_to_host_first_in_powersaving_policy.sql
 
b/packaging/dbscripts/upgrade/03_03_0990_pin_to_host_first_in_powersaving_policy.sql
new file mode 100644
index 0000000..b9a59fb
--- /dev/null
+++ 
b/packaging/dbscripts/upgrade/03_03_0990_pin_to_host_first_in_powersaving_policy.sql
@@ -0,0 +1,2 @@
+-- set the PinToHost filter as the first one in PowerSaving cluster policy
+UPDATE cluster_policy_units SET filter_sequence=-1 WHERE 
cluster_policy_id='5a2b0939-7d46-4b73-a469-e9c2c7fc6a53' and 
policy_unit_id='12262ab6-9690-4bc3-a2b3-35573b172d54';


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: If2c0496327c9f692b0dbe92e1cf481f900f4a747
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.3
Gerrit-Owner: Martin Sivák <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to