Martin Peřina has uploaded a new change for review. Change subject: core: Refactor VdsManager.isHostInGracePeriod() method ......................................................................
core: Refactor VdsManager.isHostInGracePeriod() method Makes VdsManager.isHostInGracePeriod() method public and refactor it as a part of preparation to make SSH Soft Fencing part of Non Responding Treatment. Change-Id: Iddea2ae8e923012405e5cc15badebedc74625b09 Bug-Url: https://bugzilla.redhat.com/1182510 Signed-off-by: Martin Perina <mper...@redhat.com> --- M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsManager.java 1 file changed, 24 insertions(+), 15 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/65/36965/1 diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsManager.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsManager.java index b8b11f4..3f4f77d 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsManager.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/VdsManager.java @@ -667,20 +667,12 @@ } private long calcTimeoutToFence(int vmCount, VdsSpmStatus spmStatus) { - int spmIndicator = 0; - if (spmStatus != VdsSpmStatus.None) { - spmIndicator = 1; - } + int spmIndicator = spmStatus == VdsSpmStatus.None ? 0 : 1; int secToFence = (int) ( // delay time can be fracture number, casting it to int should be enough - Config.<Integer> getValue(ConfigValues.TimeoutToResetVdsInSeconds) + - (Config.<Double> getValue(ConfigValues.DelayResetForSpmInSeconds) * spmIndicator) + - (Config.<Double> getValue(ConfigValues.DelayResetPerVmInSeconds) * vmCount)); - - if (sshSoftFencingExecuted.get()) { - // VDSM restart by SSH has been executed, wait more to see if host is OK - secToFence = 2 * secToFence; - } + Config.<Integer> getValue(ConfigValues.TimeoutToResetVdsInSeconds) + + Config.<Double> getValue(ConfigValues.DelayResetForSpmInSeconds) * spmIndicator + + Config.<Double> getValue(ConfigValues.DelayResetPerVmInSeconds) * vmCount); return TimeUnit.SECONDS.toMillis(secToFence); } @@ -695,7 +687,7 @@ boolean saveToDb = true; if (cachedVds.getStatus() != VDSStatus.Down) { long timeoutToFence = calcTimeoutToFence(cachedVds.getVmCount(), cachedVds.getSpmStatus()); - if (inGracePeriod(timeoutToFence)) { + if (isHostInGracePeriod(false)) { if (cachedVds.getStatus() != VDSStatus.Connecting && cachedVds.getStatus() != VDSStatus.PreparingForMaintenance && cachedVds.getStatus() != VDSStatus.NonResponsive) { @@ -729,8 +721,25 @@ } } - private boolean inGracePeriod(long timeoutToFence) { - return mUnrespondedAttempts.get() < Config.<Integer>getValue(ConfigValues.VDSAttemptsToResetCount) + /** + * Checks if host is in grace period from last successful communication to fencing attempt + * + * @param sshSoftFencingExecuted + * if SSH Soft Fencing was already executed we need to raise default timeout to determine if SSH Soft + * Fencing was successful and host became Up + * @return <code>true</code> if host is still in grace period, otherwise <code>false</code> + */ + public boolean isHostInGracePeriod(boolean sshSoftFencingExecuted) { + long timeoutToFence = calcTimeoutToFence(cachedVds.getVmCount(), cachedVds.getSpmStatus()); + int unrespondedAttemptsBarrier = Config.<Integer>getValue(ConfigValues.VDSAttemptsToResetCount); + + if (sshSoftFencingExecuted) { + // SSH Soft Fencing has already been executed, increase timeout to see if host is OK + timeoutToFence = timeoutToFence * 2; + unrespondedAttemptsBarrier = unrespondedAttemptsBarrier * 2; + } + + return mUnrespondedAttempts.get() < unrespondedAttemptsBarrier || (lastUpdate + timeoutToFence) > System.currentTimeMillis(); } -- To view, visit http://gerrit.ovirt.org/36965 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iddea2ae8e923012405e5cc15badebedc74625b09 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Martin Peřina <mper...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches