Jiří Moskovčák has uploaded a new change for review.

Change subject: core: check if the HE guest can be migrated before maintenace
......................................................................

core: check if the HE guest can be migrated before maintenace

When putting VDS to maintenance mode the HE guest is migrated by the
ha-agent so it's not checked by the engine at all. In case there is no
VDS to migrate the HE guest to the migration will never happen and
the host stays in "preparing for maintenance" until the admin activates
it manually. This patch adds the logic to check if there is a VDS
which can be used for HE guest. It's a bit racy, but it will prevent
at least the case described in the referenced bugzilla.

Change-Id: I0b9cbcd03f01ca34c6c31308b7321214e15cafc7
Bug-Url: https://bugzilla.redhat.com/1157378
Signed-off-by: Jiri Moskovcak <jmosk...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceVdsCommand.java
1 file changed, 17 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/01/35401/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceVdsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceVdsCommand.java
index 84cf829..81b15bf 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceVdsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceVdsCommand.java
@@ -8,6 +8,7 @@
 import org.ovirt.engine.core.bll.context.CommandContext;
 import org.ovirt.engine.core.bll.job.ExecutionContext;
 import org.ovirt.engine.core.bll.job.ExecutionHandler;
+import org.ovirt.engine.core.bll.scheduling.SchedulingManager;
 import org.ovirt.engine.core.common.AuditLogType;
 import org.ovirt.engine.core.common.VdcObjectType;
 import org.ovirt.engine.core.common.action.InternalMigrateVmParameters;
@@ -104,6 +105,16 @@
         return migrateAllVms(parentContext, false);
     }
 
+    private boolean canScheduleVm(VM vm) {
+        return SchedulingManager.getInstance().canSchedule(
+                        getVdsGroup(),
+                        getVm(),
+                        new ArrayList<Guid>(), //no blacklist
+                        new ArrayList<Guid>(), //no whitelist
+                        vm.getDedicatedVmForVds(),
+                        new ArrayList<String>()
+                        );
+    }
     /**
      * Note: you must call {@link #orderListOfRunningVmsOnVds(Guid)} before 
calling this method
      */
@@ -113,8 +124,12 @@
 
         for (VM vm : vms) {
             if (vm.isHostedEngine()) {
-                // The Hosted Engine vm is migrated by the HA agent
-                continue;
+                // check if there is host which can be used for HE
+                if (!canScheduleVm(vm)) {
+                    succeeded = false;
+                    appendCustomValue("failedVms", vm.getName(), ",");
+                    log.error("ResourceManager::vdsMaintenance - There is not 
host capable of running the hosted engine VM");
+                }
             }
             // if HAOnly is true check that vm is HA (auto_startup should be 
true)
             if (vm.getStatus() != VMStatus.MigratingFrom && (!HAOnly || 
(HAOnly && vm.isAutoStartup()))) {


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0b9cbcd03f01ca34c6c31308b7321214e15cafc7
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Jiří Moskovčák <jmosk...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to