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

Change subject: core: don't throw an exception, when moving unresponsive VDS to 
maintenance
......................................................................

core: don't throw an exception, when moving unresponsive VDS to maintenance

When VDS which is part of hosted engine cluster becoms non-responsive,
it throws an exception when running SetHaMaintenance command which
results in roll back of the whole maintenance command preventing
user from removing the broken VDS

Change-Id: Ibf9b489f73793ea1135a72bf1a9184e0822386d8
Bug-Url: https://bugzilla.redhat.com/1162998
Signed-off-by: Jiri Moskovcak <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/MaintenanceVdsCommand.java
1 file changed, 21 insertions(+), 10 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/69/35269/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..b082ef7 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
@@ -21,6 +21,7 @@
 import org.ovirt.engine.core.common.businessentities.VM;
 import org.ovirt.engine.core.common.businessentities.VMStatus;
 import org.ovirt.engine.core.common.businessentities.comparators.VmsComparer;
+import org.ovirt.engine.core.common.errors.VdcBLLException;
 import org.ovirt.engine.core.common.errors.VdcBllMessages;
 import org.ovirt.engine.core.common.job.Step;
 import org.ovirt.engine.core.common.job.StepEnum;
@@ -48,6 +49,15 @@
         haMaintenanceFailed = false;
     }
 
+    private boolean isHostedEngineOnVds() {
+        for (VM vm : vms) {
+            if (vm.isHostedEngine()) {
+                return true;
+            }
+        }
+        return false;
+    }
+
     @Override
     protected void executeCommand() {
         if (getVds().getStatus() == VDSStatus.Maintenance) {
@@ -57,16 +67,17 @@
             orderListOfRunningVmsOnVds(getVdsId());
 
             if (getVds().getHighlyAvailableIsConfigured()) {
-                SetHaMaintenanceModeVDSCommandParameters params
-                        = new 
SetHaMaintenanceModeVDSCommandParameters(getVds(), HaMaintenanceMode.LOCAL, 
true);
-                if (!runVdsCommand(VDSCommandType.SetHaMaintenanceMode, 
params).getSucceeded()) {
-                    // HA maintenance failure is fatal only if the Hosted 
Engine vm is running on this host
-                    for (VM vm : vms) {
-                        if (vm.isHostedEngine()) {
-                            setSucceeded(false);
-                            return;
-                        }
+                try {
+                    SetHaMaintenanceModeVDSCommandParameters params
+                            = new 
SetHaMaintenanceModeVDSCommandParameters(getVds(), HaMaintenanceMode.LOCAL, 
true);
+                    if (!runVdsCommand(VDSCommandType.SetHaMaintenanceMode, 
params).getSucceeded()) {
+                        // HA maintenance failure is fatal only if the Hosted 
Engine vm is running on this host
+                        setSucceeded(isHostedEngineOnVds());
+                        haMaintenanceFailed = true;
                     }
+                }
+                catch (VdcBLLException e) {
+                    setSucceeded(isHostedEngineOnVds());
                     haMaintenanceFailed = true;
                 }
             }
@@ -78,7 +89,7 @@
                     || getVds().getStatus() == VDSStatus.Connecting
                     || getVds().getStatus() == VDSStatus.Down) {
                 runVdsCommand(VDSCommandType.SetVdsStatus,
-                                new 
SetVdsStatusVDSCommandParameters(getVdsId(), VDSStatus.Maintenance));
+                        new SetVdsStatusVDSCommandParameters(getVdsId(), 
VDSStatus.Maintenance));
             }
         }
         // if there's VM(s) in this VDS which is migrating, mark this command 
as async


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ibf9b489f73793ea1135a72bf1a9184e0822386d8
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Jiří Moskovčák <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to