Eli Mesika has uploaded a new change for review.

Change subject: core: RFE: Multi-Tier fencing
......................................................................

core: RFE: Multi-Tier fencing

This patch fixes a bug in the multiple sequential PM agent treatment.
The secondary agent was used only if the primary agent was configured OK
and the fence command was sent successfully to it and it fails to perform
the command after the configured wait/retries.
This patch change this behaviour to use the secondary agent also if the
primary agent was not configured well or from some reason can not be
used although having the correct configuration (can not be accessed for
example due to networking issue)

Change-Id: I8ee542e7ddaec1bcdc777295b8222aceed798ed9
Signed-off-by: Eli Mesika <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
1 file changed, 40 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/85/12785/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
index 63caba4..7b962c5 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
@@ -196,10 +196,10 @@
                 if (waitForStatus(getVds().getName(), 
getParameters().getAction(), FenceAgentOrder.Primary)) {
                     handleSpecificCommandActions();
                 } else {
-                    handleWaitFailure(lastStatus);
+                    handleWaitFailure(lastStatus, FenceAgentOrder.Primary);
                 }
             } else {
-                handleError(lastStatus, vdsReturnValue);
+                handleError(lastStatus, vdsReturnValue, 
FenceAgentOrder.Primary);
             }
         }
     }
@@ -219,24 +219,32 @@
                 if (waitForStatus(getVds().getName(), 
getParameters().getAction(), FenceAgentOrder.Primary)) {
                     handleSpecificCommandActions();
                 } else {
-                    vdsReturnValue = executor.Fence(FenceAgentOrder.Secondary);
-                    setFenceSucceeded(vdsReturnValue.getSucceeded());
-                    if (getFenceSucceeded()) {
-                        executor = new FenceExecutor(getVds(), 
FenceActionType.Status);
-                        if (waitForStatus(getVds().getName(), 
getParameters().getAction(),FenceAgentOrder.Secondary)) {
-                            handleSpecificCommandActions();
-                        }
-                        else {
-                            handleWaitFailure(lastStatus);
-                        }
-                    }
-                    else {
-                        handleError(lastStatus, vdsReturnValue);
-                    }
+                    tryOtherSequentialAgent(lastStatus);
                 }
             } else {
-                handleError(lastStatus, vdsReturnValue);
+                tryOtherSequentialAgent(lastStatus);
             }
+        }
+    }
+
+    /**
+     * fence the Host via the secondary agent if primary fails
+     * @param lastStatus
+     */
+    private void tryOtherSequentialAgent(VDSStatus lastStatus) {
+        VDSReturnValue vdsReturnValue = 
executor.Fence(FenceAgentOrder.Secondary);
+        setFenceSucceeded(vdsReturnValue.getSucceeded());
+        if (getFenceSucceeded()) {
+            executor = new FenceExecutor(getVds(), FenceActionType.Status);
+            if (waitForStatus(getVds().getName(), 
getParameters().getAction(),FenceAgentOrder.Secondary)) {
+                handleSpecificCommandActions();
+            }
+            else {
+                handleWaitFailure(lastStatus, FenceAgentOrder.Secondary);
+            }
+        }
+        else {
+            handleError(lastStatus, vdsReturnValue, FenceAgentOrder.Secondary);
         }
     }
 
@@ -277,12 +285,12 @@
                     handleSpecificCommandActions();
                     setFenceSucceeded(true);
                 } else {
-                    tryOtherAgent(lastStatus, ecs);
+                    tryOtherConcurrentAgent(lastStatus, ecs);
                 }
                 } catch (InterruptedException e) {
-                    tryOtherAgent(lastStatus, ecs);
+                    tryOtherConcurrentAgent(lastStatus, ecs);
                 } catch (ExecutionException e) {
-                    tryOtherAgent(lastStatus, ecs);
+                    tryOtherConcurrentAgent(lastStatus, ecs);
                 }
 
                 break;
@@ -302,7 +310,8 @@
                     setFenceSucceeded(true);
                 } else {
                     handleError(lastStatus,
-                            (!primaryResult.isSucceeded()) ? 
primaryResult.getValue() : secondaryResult.getValue());
+                            !primaryResult.isSucceeded() ? 
primaryResult.getValue() : secondaryResult.getValue(),
+                            !primaryResult.isSucceeded() ? 
FenceAgentOrder.Primary : FenceAgentOrder.Secondary);
                 }
                 break;
             default:
@@ -316,7 +325,7 @@
         }
     }
 
-    private void tryOtherAgent(VDSStatus lastStatus, 
ExecutorCompletionService<FenceInvocationResult> ecs)
+    private void tryOtherConcurrentAgent(VDSStatus lastStatus, 
ExecutorCompletionService<FenceInvocationResult> ecs)
             throws InterruptedException, ExecutionException {
         Future<FenceInvocationResult> f2;
         f2 = ecs.take();
@@ -325,8 +334,8 @@
             handleSpecificCommandActions();
             setFenceSucceeded(true);
         } else {
-            handleError(lastStatus, primaryResult.getValue());
-            handleError(lastStatus, secondaryResult.getValue());
+            handleError(lastStatus, 
primaryResult.getValue(),FenceAgentOrder.Primary);
+            handleError(lastStatus, secondaryResult.getValue(), 
FenceAgentOrder.Secondary);
         }
     }
 
@@ -349,7 +358,7 @@
         }
         return fenceInvocationResult;
     }
-    private void handleWaitFailure(VDSStatus lastStatus) {
+    private void handleWaitFailure(VDSStatus lastStatus, FenceAgentOrder 
order) {
         VDSReturnValue vdsReturnValue;
         // since there is a chance that Agent & Host use the same power supply 
and
         // a Start command had failed (because we just get success on the 
script
@@ -357,17 +366,17 @@
         // before giving up
         if (getParameters().getAction() == FenceActionType.Start) {
             executor = new FenceExecutor(getVds(), FenceActionType.Start);
-            vdsReturnValue = executor.Fence();
+            vdsReturnValue = executor.Fence(order);
             setFenceSucceeded(vdsReturnValue.getSucceeded());
             if (getFenceSucceeded()) {
                 executor = new FenceExecutor(getVds(), FenceActionType.Status);
-                if (waitForStatus(getVds().getName(), FenceActionType.Start, 
FenceAgentOrder.Primary)) {
+                if (waitForStatus(getVds().getName(), 
FenceActionType.Start,order)) {
                     handleSpecificCommandActions();
                 } else {
                     setFenceSucceeded(false);
                 }
             } else {
-                handleError(lastStatus, vdsReturnValue);
+                handleError(lastStatus, vdsReturnValue, order);
             }
 
         } else {
@@ -379,13 +388,13 @@
         }
     }
 
-    private void handleError(VDSStatus lastStatus, final VDSReturnValue 
vdsReturnValue) {
+    private void handleError(VDSStatus lastStatus, final VDSReturnValue 
vdsReturnValue, FenceAgentOrder order) {
         if (!((FenceStatusReturnValue) 
(vdsReturnValue.getReturnValue())).getIsSkipped()) {
             // Since this is a non-transactive command , restore last status
             setSucceeded(false);
-            log.errorFormat("Failed to {0} VDS", getParameters().getAction()
+            log.errorFormat("Failed to {0} VDS using {1} Power Management 
agent", getParameters().getAction()
                     .name()
-                    .toLowerCase());
+                    .toLowerCase(), order.name());
             throw new VdcBLLException(VdcBllErrors.VDS_FENCE_OPERATION_FAILED);
         } else { // Fence operation was skipped because Host is already in the 
requested state.
             setStatus(lastStatus);


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I8ee542e7ddaec1bcdc777295b8222aceed798ed9
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Eli Mesika <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to