Martin Peřina has uploaded a new change for review.

Change subject: core: Fix displaying result of VdsNotRespondingTreatment
......................................................................

core: Fix displaying result of VdsNotRespondingTreatment

Fixes displaying result of VdsNotRespondingTreatment command for cases
where cluster fencing policy contains skip fencing if host has live
lease on storage turned on. With this patch it's properly shown that
stop vds and restart vds was not successfull dues to host live lease on
storage.

Change-Id: Ia864b986dd453920144ad1556c9f9d020da97c20
Bug-Url: https://bugzilla.redhat.com/1090799
Signed-off-by: Martin Perina <mper...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/FenceVdsBaseCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestartVdsCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVdsCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsNotRespondingTreatmentCommand.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
6 files changed, 49 insertions(+), 30 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/39/31239/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 09f0329..cd43c3d 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
@@ -54,6 +54,8 @@
     private FenceInvocationResult primaryResult;
     private FenceInvocationResult secondaryResult;
 
+    protected boolean skippedDueToFencingPolicy;
+
     /**
      * Constructor for command creation when compensation is applied on startup
      *
@@ -61,6 +63,7 @@
      */
     protected FenceVdsBaseCommand(Guid commandId) {
         super(commandId);
+        skippedDueToFencingPolicy = false;
     }
 
     public FenceVdsBaseCommand(T parameters) {
@@ -70,6 +73,7 @@
     public FenceVdsBaseCommand(T parameters, CommandContext commandContext) {
         super(parameters, commandContext);
         mVmList = getVmDAO().getAllRunningForVds(getVdsId());
+        skippedDueToFencingPolicy = false;
     }
 
     /**
@@ -182,7 +186,10 @@
         } finally {
             if (!getSucceeded()) {
                 setStatus(lastStatus);
-                AlertIfPowerManagementOperationFailed();
+                if (!skippedDueToFencingPolicy) {
+                    // show alert only if command was not skipped due to 
fencing policy
+                    AlertIfPowerManagementOperationFailed();
+                }
             }
 
             // Successful fencing with reboot or shutdown op. Clear the power 
management policy flag
@@ -668,8 +675,9 @@
     }
 
     private void handleFencingSkippedDueToPolicy(VDSReturnValue 
vdsReturnValue) {
-        setFenceSucceeded(true);
-        vdsReturnValue.setSucceeded(true);
-        vdsReturnValue.setReturnValue(FenceStatusReturnValue.SKIPPED);
+        skippedDueToFencingPolicy = true;
+        setFenceSucceeded(false);
+        vdsReturnValue.setSucceeded(false);
+        setActionReturnValue(vdsReturnValue.getReturnValue());
     }
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestartVdsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestartVdsCommand.java
index 2619256..f1e5d17 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestartVdsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/RestartVdsCommand.java
@@ -4,7 +4,6 @@
 import static org.ovirt.engine.core.common.AuditLogType.SYSTEM_VDS_RESTART;
 import static 
org.ovirt.engine.core.common.AuditLogType.USER_FAILED_VDS_RESTART;
 import static org.ovirt.engine.core.common.AuditLogType.USER_VDS_RESTART;
-import static 
org.ovirt.engine.core.common.AuditLogType.VDS_NOT_RESTARTED_DUE_TO_POLICY;
 import static 
org.ovirt.engine.core.common.errors.VdcBllMessages.VAR__ACTION__RESTART;
 import static 
org.ovirt.engine.core.common.errors.VdcBllMessages.VAR__TYPE__HOST;
 import static 
org.ovirt.engine.core.common.errors.VdcBllMessages.VDS_FENCE_OPERATION_FAILED;
@@ -45,8 +44,6 @@
 @NonTransactiveCommandAttribute
 public class RestartVdsCommand<T extends FenceVdsActionParameters> extends 
FenceVdsBaseCommand<T> {
 
-    private boolean skippedDueToFencingPolicy;
-
     protected List<VM> getVmList() {
         return mVmList;
     }
@@ -58,7 +55,6 @@
      */
     protected RestartVdsCommand(Guid commandId) {
         super(commandId);
-        skippedDueToFencingPolicy = false;
     }
 
     public RestartVdsCommand(T parameters) {
@@ -67,7 +63,6 @@
 
     public RestartVdsCommand(T parameters, CommandContext commandContext) {
         super(parameters, commandContext);
-        skippedDueToFencingPolicy = false;
     }
 
 
@@ -93,21 +88,22 @@
             // execute StopVds action
             returnValueBase = executeVdsFenceAction(vdsId, sessionId, 
FenceActionType.Stop, VdcActionType.StopVds);
         }
+        if (wasSkippedDueToPolicy(returnValueBase.getActionReturnValue())) {
+            // fence execution was skipped due to fencing policy, host should 
be alive
+            setSucceeded(false);
+            setFenceSucceeded(false);
+            skippedDueToFencingPolicy = true;
+            runVdsCommand(VDSCommandType.SetVdsStatus, new 
SetVdsStatusVDSCommandParameters(vdsId,
+                    VDSStatus.NonResponsive));
+            return;
+        }
         if (returnValueBase.getSucceeded()) {
-            if (wasSkippedDueToPolicy(returnValueBase.getActionReturnValue())) 
{
-                // fence execution was skipped due to fencing policy, host 
should be alive
-                setSucceeded(true);
-                setFenceSucceeded(true);
-                skippedDueToFencingPolicy = true;
-                return;
-            } else {
-                executeFenceVdsManuallyAction(vdsId, sessionId);
+            executeFenceVdsManuallyAction(vdsId, sessionId);
 
-                // execute StartVds action
-                returnValueBase = executeVdsFenceAction(vdsId, sessionId, 
FenceActionType.Start, VdcActionType.StartVds);
-                setSucceeded(returnValueBase.getSucceeded());
-                setFenceSucceeded(getSucceeded());
-            }
+            // execute StartVds action
+            returnValueBase = executeVdsFenceAction(vdsId, sessionId, 
FenceActionType.Start, VdcActionType.StartVds);
+            setSucceeded(returnValueBase.getSucceeded());
+            setFenceSucceeded(getSucceeded());
         } else {
             super.handleError();
             setSucceeded(false);
@@ -164,11 +160,7 @@
     @Override
     public AuditLogType getAuditLogTypeValue() {
         if (getSucceeded()) {
-            if (skippedDueToFencingPolicy) {
-                return VDS_NOT_RESTARTED_DUE_TO_POLICY;
-            } else {
-                return isInternalExecution() ? SYSTEM_VDS_RESTART : 
USER_VDS_RESTART;
-            }
+            return isInternalExecution() ? SYSTEM_VDS_RESTART : 
USER_VDS_RESTART;
         } else {
             return isInternalExecution() ? SYSTEM_FAILED_VDS_RESTART : 
USER_FAILED_VDS_RESTART;
         }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVdsCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVdsCommand.java
index d5cb8cc..d509c91 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVdsCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/StopVdsCommand.java
@@ -86,7 +86,13 @@
 
     @Override
     public AuditLogType getAuditLogTypeValue() {
-        return getSucceeded() ? AuditLogType.USER_VDS_STOP : 
AuditLogType.USER_FAILED_VDS_STOP;
+        if (getSucceeded()) {
+            return AuditLogType.USER_VDS_STOP;
+        } else {
+            return skippedDueToFencingPolicy ?
+                    AuditLogType.VDS_NOT_STOPPED_DUE_TO_POLICY :
+                    AuditLogType.USER_FAILED_VDS_STOP;
+        }
     }
 
     @Override
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsNotRespondingTreatmentCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsNotRespondingTreatmentCommand.java
index 7f797b4..ae51978 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsNotRespondingTreatmentCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsNotRespondingTreatmentCommand.java
@@ -124,7 +124,11 @@
             log.infoFormat("Host {0}({1}) not fenced since it's status is ok, 
or it doesn't exist anymore.",
                     getVdsName(), getVdsId());
         }
-        getReturnValue().setSucceeded(shouldBeFenced);
+        if (skippedDueToFencingPolicy) {
+            setSucceeded(false);
+        } else {
+            getReturnValue().setSucceeded(shouldBeFenced);
+        }
     }
 
     @Override
@@ -148,7 +152,13 @@
 
     @Override
     public AuditLogType getAuditLogTypeValue() {
-        return getSucceeded() ? AuditLogType.VDS_RECOVER : 
AuditLogType.VDS_RECOVER_FAILED;
+        if (getSucceeded()) {
+            return AuditLogType.VDS_RECOVER;
+        } else {
+            return skippedDueToFencingPolicy ?
+                    AuditLogType.VDS_NOT_RESTARTED_DUE_TO_POLICY :
+                    AuditLogType.VDS_RECOVER_FAILED;
+        }
     }
 
     @Override
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
index ff56c1c..2fcdd68 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/AuditLogType.java
@@ -104,6 +104,7 @@
     SYSTEM_FAILED_VDS_RESTART(122, AuditLogSeverity.ERROR,
             AuditLogTimeInterval.MINUTE.getValue()),
     VDS_NOT_RESTARTED_DUE_TO_POLICY(618),
+    VDS_NOT_STOPPED_DUE_TO_POLICY(619),
 
     // Host time drift Alert
     VDS_TIME_DRIFT_ALERT(604, AuditLogSeverity.WARNING,
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 0dcf127..22dc94a 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -576,6 +576,8 @@
 NETWORK_COMMINT_NETWORK_CHANGES_FAILED=Failed to commit network changes on 
${VdsName}
 SYSTEM_VDS_RESTART=Host ${VdsName} was restarted by the engine.
 SYSTEM_FAILED_VDS_RESTART=A restart initiated by the engine to Host ${VdsName} 
has failed.
+VDS_NOT_RESTARTED_DUE_TO_POLICY=Host ${VdsName} was not restarted due to 
fencing policy.
+VDS_NOT_STOPPED_DUE_TO_POLICY=Host ${VdsName} was not stopped due to fencing 
policy.
 VDS_TIME_DRIFT_ALERT=Host ${VdsName} has time-drift of ${Actual} seconds while 
maximum configured value is ${Max} seconds.
 PROXY_HOST_SELECTION=Host ${Proxy} from ${Origin} was chosen as a proxy to 
execute ${Command} command on Host ${VdsName}.
 RECONSTRUCT_MASTER_FAILED_NO_MASTER=No valid Data Storage Domains are 
available in Data Center ${StoragePoolName} (please check your storage 
infrastructure).


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ia864b986dd453920144ad1556c9f9d020da97c20
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.5
Gerrit-Owner: Martin Peřina <mper...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to