Eli Mesika has uploaded a new change for review.

Change subject: core: Skip hard fencing if network unstable...
......................................................................

core: Skip hard fencing if network unstable...

Skip hard fencing if unstable network threshold reached

Change-Id: Iff1b4108da76286907773575c101c73aaacbca41
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1120829
Signed-off-by: Eli Mesika <[email protected]>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
1 file changed, 26 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/04/31304/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
index 4fd7c4d..171148e 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsEventListener.java
@@ -45,6 +45,8 @@
 import org.ovirt.engine.core.common.businessentities.StoragePool;
 import org.ovirt.engine.core.common.businessentities.StoragePoolStatus;
 import org.ovirt.engine.core.common.businessentities.VDS;
+import org.ovirt.engine.core.common.businessentities.VDSGroup;
+import org.ovirt.engine.core.common.businessentities.VDSStatus;
 import org.ovirt.engine.core.common.businessentities.VmDynamic;
 import org.ovirt.engine.core.common.businessentities.VmStatic;
 import 
org.ovirt.engine.core.common.businessentities.gluster.GlusterBrickEntity;
@@ -72,6 +74,7 @@
 import org.ovirt.engine.core.utils.ejb.EjbUtils;
 import org.ovirt.engine.core.utils.linq.Function;
 import org.ovirt.engine.core.utils.linq.LinqUtils;
+import org.ovirt.engine.core.utils.linq.Predicate;
 import org.ovirt.engine.core.utils.lock.EngineLock;
 import org.ovirt.engine.core.utils.lock.LockManagerFactory;
 import org.ovirt.engine.core.utils.log.Log;
@@ -234,7 +237,7 @@
                         vds.getId(),
                         vds.getHostName());
 
-                boolean shouldExecRealFencing = true;
+                boolean shouldExecRealFencing = 
isBelowNetworkUnstableThreshold(vds);
 
                 if (executeSshSoftFencing) {
                     VdcReturnValueBase retVal =
@@ -243,7 +246,7 @@
                                     
ExecutionHandler.createInternalJobContext());
                     // if SSH Soft Fencing command execution was successful, 
do not execute
                     // standard fencing immediately, but wait to see if it 
helped
-                    shouldExecRealFencing = !retVal.getSucceeded();
+                    shouldExecRealFencing = shouldExecRealFencing && 
!retVal.getSucceeded();
                 }
 
                 if 
(MonitoringStrategyFactory.getMonitoringStrategyForVds(vds).isPowerManagementSupported()
@@ -258,8 +261,29 @@
                 }
                 moveBricksToUnknown(vds);
             }
+
+
         });
     }
+    private boolean isBelowNetworkUnstableThreshold(VDS vds) {
+        VDSGroup cluster = 
DbFacade.getInstance().getVdsGroupDao().get(vds.getVdsGroupId());
+        boolean result = true;
+        if (cluster.getFencingPolicy().isSkipFencingIfNetworkUnstable()) {
+            List<VDS> hosts = 
DbFacade.getInstance().getVdsDao().getAllForVdsGroup(cluster.getId());
+            double hostsNumber = hosts.size();
+            List<VDS> hostsWithUnstableNetwork = LinqUtils.filter(hosts,
+                    new Predicate<VDS>() {
+                        @Override
+                        public boolean eval(VDS a) {
+                            return (a.getStatus() == VDSStatus.Connecting || 
a.getStatus() == VDSStatus.NonResponsive);
+                        }
+                    });
+            double hostsWithUnstableNetworkNumber = 
hostsWithUnstableNetwork.size();
+            result = ((hostsWithUnstableNetworkNumber/hostsNumber)*100.0) < 
cluster.getFencingPolicy().getHostsWithUnstableNetworkThreshold();
+        }
+        return result;
+    }
+
 
     private void moveBricksToUnknown(final VDS vds) {
         List<GlusterBrickEntity> brickEntities = 
DbFacade.getInstance().getGlusterBrickDao().getGlusterVolumeBricksByServerId(vds.getId());


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iff1b4108da76286907773575c101c73aaacbca41
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