Eli Mesika has uploaded a new change for review. Change subject: core: [RFE] Restart HA VMs ASAP ......................................................................
core: [RFE] Restart HA VMs ASAP [RFE] Restart HA VMs when power management reports host is in powered off state This patch changes the following flows 1) soft-fencing : if Host has PM configured, check host status and if it is off , skip soft-fencing and put host status to DOWN 2) Restart : if Host has PM configured, check host status and if it is off , skip the stop command and put host status to DOWN The result of that is a faster HA VMs release on the fenced host and restart on another host saving us unnecessary retries and wait time. Change-Id: Iaca0111d13a625014fb424bdccd3709b8ea03382 Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1058737 Signed-off-by: Eli Mesika <[email protected]> --- 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/SshSoftFencingCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsCommand.java 3 files changed, 79 insertions(+), 17 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/85/27985/1 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 6d76779..8fa2d1e 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 @@ -68,12 +68,18 @@ */ @Override protected void executeCommand() { - VdcReturnValueBase returnValueBase; + VdcReturnValueBase returnValueBase = new VdcReturnValueBase(); final Guid vdsId = getVdsId(); final String sessionId = getParameters().getSessionId(); - // execute StopVds action - returnValueBase = executeVdsFenceAction(vdsId, sessionId, FenceActionType.Stop, VdcActionType.StopVds); + // do not try to stop Host if Host is reported as Down via PM + if (isPmReportsStatusDown()) { + returnValueBase.setSucceeded(true); + } + else { + // execute StopVds action + returnValueBase = executeVdsFenceAction(vdsId, sessionId, FenceActionType.Stop, VdcActionType.StopVds); + } if (returnValueBase.getSucceeded()) { executeFenceVdsManuallyAction(vdsId, sessionId); diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SshSoftFencingCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SshSoftFencingCommand.java index ef08ccf..a7531bb 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SshSoftFencingCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SshSoftFencingCommand.java @@ -38,22 +38,27 @@ getReturnValue().setSucceeded(false); return; } - - VdsValidator validator = new VdsValidator(getVds()); - if (validator.shouldVdsBeFenced()) { - boolean result = executeSshSoftFencingCommand(getVds().getVdsGroupCompatibilityVersion().toString()); - if (result) { - // SSH Soft Fencing executed without errors, tell VdsManager about it - ResourceManager.getInstance().GetVdsManager(getVds().getId()).finishSshSoftFencingExecution(getVds()); - } - getReturnValue().setSucceeded(result); - } else { - setCommandShouldBeLogged(false); - log.infoFormat("SSH Soft Fencing will not be executed on host {0}({1}) since it's status is ok.", - getVdsName(), - getVdsId()); + if (isPmReportsStatusDown()) { + // do not try to soft-fence if Host is reported as Down via PM getReturnValue().setSucceeded(false); } + else { + VdsValidator validator = new VdsValidator(getVds()); + if (validator.shouldVdsBeFenced()) { + boolean result = executeSshSoftFencingCommand(getVds().getVdsGroupCompatibilityVersion().toString()); + if (result) { + // SSH Soft Fencing executed without errors, tell VdsManager about it + ResourceManager.getInstance().GetVdsManager(getVds().getId()).finishSshSoftFencingExecution(getVds()); + } + getReturnValue().setSucceeded(result); + } else { + setCommandShouldBeLogged(false); + log.infoFormat("SSH Soft Fencing will not be executed on host {0}({1}) since it's status is ok.", + getVdsName(), + getVdsId()); + getReturnValue().setSucceeded(false); + } + } } /** diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsCommand.java index afac7cc..4ff10c9 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsCommand.java @@ -8,6 +8,9 @@ import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.common.VdcObjectType; import org.ovirt.engine.core.common.action.VdsActionParameters; +import org.ovirt.engine.core.common.businessentities.FenceActionType; +import org.ovirt.engine.core.common.businessentities.FenceAgentOrder; +import org.ovirt.engine.core.common.businessentities.FenceStatusReturnValue; import org.ovirt.engine.core.common.businessentities.VDS; import org.ovirt.engine.core.common.businessentities.VDSStatus; import org.ovirt.engine.core.common.businessentities.VdsStatic; @@ -301,4 +304,52 @@ return status; } } + + /** + * Checks if Host status is Down via its PM card (if defined) + * @param vds + * The host to check + * @return + * boolean + */ + protected boolean isPmReportsStatusDown() { + boolean result = false; + VDS vds = getVds(); + VDSReturnValue returnValue=null; + // Check first if Host has configured PM + if (vds != null && vds.getpm_enabled()) { + FenceExecutor executor = new FenceExecutor(vds, FenceActionType.Status); + if (executor.findProxyHost()) { + // try to get status via Primary card + returnValue = executor.fence(FenceAgentOrder.Primary); + if (returnValue.getSucceeded()) { + result = isHostStatusOff(returnValue); + } + // try to get status via Secondary card (if configured) + if (!result && !StringUtils.isEmpty(vds.getPmSecondaryIp())) { + returnValue = executor.fence(FenceAgentOrder.Secondary); + if (returnValue.getSucceeded()) { + result = isHostStatusOff(returnValue); + } + } + } + } + if (result) { + Backend.getInstance() + .getResourceManager() + .RunVdsCommand(VDSCommandType.SetVdsStatus, + new SetVdsStatusVDSCommandParameters(getVds().getId(), VDSStatus.Down)); + } + return result; + } + + private static boolean isHostStatusOff(VDSReturnValue returnValue) { + String OFF = "off"; + boolean result = false; + if (returnValue != null && returnValue.getReturnValue() != null) { + FenceStatusReturnValue value = (FenceStatusReturnValue) returnValue.getReturnValue(); + result = value.getStatus().equalsIgnoreCase(OFF); + } + return result; + } } -- To view, visit http://gerrit.ovirt.org/27985 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iaca0111d13a625014fb424bdccd3709b8ea03382 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
