Martin Peřina has uploaded a new change for review. Change subject: core: Add kdump detection into fencing flow ......................................................................
core: Add kdump detection into fencing flow Adds kdump detection implemented in VdsKdumpDetectionCommand into fencing flow. Change-Id: I18145bc5814dc0b97b8ed6593f0c76473285ae16 Bug-Url: https://bugzilla.redhat.com/1079821 Signed-off-by: Martin Perina <mper...@redhat.com> --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java A backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsKdumpDetectionCommand.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/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java M backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties M backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties 7 files changed, 128 insertions(+), 1 deletion(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/72/28072/1 diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java index 77df6dd..b4bab52 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java @@ -114,6 +114,9 @@ boolean initSucceeded = true; + // host is UP, remove kdump status + getDbFacade().getVdsKdumpStatusDao().remove(getVdsId()); + /* Host is UP, re-set the policy controlled power management flag */ getVds().setPowerManagementControlledByPolicy(true); DbFacade.getInstance().getVdsDynamicDao().updateVdsDynamicPowerManagementPolicyFlag( @@ -530,5 +533,4 @@ return false; } } - } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsKdumpDetectionCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsKdumpDetectionCommand.java new file mode 100644 index 0000000..d64b32f --- /dev/null +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/VdsKdumpDetectionCommand.java @@ -0,0 +1,105 @@ +package org.ovirt.engine.core.bll; + +import java.util.Calendar; + +import org.ovirt.engine.core.common.AuditLogType; +import org.ovirt.engine.core.common.action.VdsActionParameters; +import org.ovirt.engine.core.common.businessentities.KdumpFlowStatus; +import org.ovirt.engine.core.common.businessentities.KdumpStatus; +import org.ovirt.engine.core.common.businessentities.VDSStatus; +import org.ovirt.engine.core.common.businessentities.VdsKdumpStatus; +import org.ovirt.engine.core.common.config.Config; +import org.ovirt.engine.core.common.config.ConfigValues; +import org.ovirt.engine.core.common.vdscommands.SetVdsStatusVDSCommandParameters; +import org.ovirt.engine.core.common.vdscommands.VDSCommandType; +import org.ovirt.engine.core.dal.dbbroker.DbFacade; +import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector; +import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase; +import org.ovirt.engine.core.utils.ThreadUtils; + +/** + * Tries to detect if VDS is kdumping. + */ +@NonTransactiveCommandAttribute +public class VdsKdumpDetectionCommand<T extends VdsActionParameters> extends VdsCommand<T> { + public VdsKdumpDetectionCommand(T parameters) { + super(parameters); + } + + @Override + protected boolean canDoAction() { + if (getVds().getKdumpStatus() != KdumpStatus.ENABLED) { + log.infoFormat("Kdump detection support is not configured on host {0}({1}).", + getVdsName(), + getVdsId()); + return false; + } + return getVds().isPmKdumpDetection(); + } + + /** + * If the VDS is not responding, it tries to detect if VDS is kdumping or not. + */ + @Override + protected void executeCommand() { + setVds(null); + if (getVds() == null) { + setCommandShouldBeLogged(false); + log.infoFormat("Kdump detection will not be executed on host {0}({1}) since it doesn't exist anymore.", + getVdsName(), + getVdsId()); + getReturnValue().setSucceeded(false); + return; + } + + boolean detected = false; + int interval = Config.<Integer>getValue(ConfigValues.FenceKdumpMessageInterval) * 1000; + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.SECOND, Config.<Integer>getValue(ConfigValues.KdumpStartedTimeout)); + long timeout = cal.getTimeInMillis(); + DbFacade dbf = DbFacade.getInstance(); + VdsKdumpStatus kdumpStatus = dbf.getVdsKdumpStatusDao().get(getVdsId()); + + while (!detected && timeout > System.currentTimeMillis()) { + detected = kdumpStatus != null; + if (!detected) { + ThreadUtils.sleep(interval); + } + kdumpStatus = dbf.getVdsKdumpStatusDao().get(getVdsId()); + } + + if (detected) { + AuditLogableBase base = new AuditLogableBase(); + base.setVds(getVds()); + AuditLogDirector.log(base, AuditLogType.KDUMP_FLOW_DETECTED_ON_VDS); + } else { + log.infoFormat("Kdump not detected on host {0}({1}).", + getVdsName(), + getVdsId()); + getReturnValue().setSucceeded(false); + return; + } + + // kdump detected set status to reboot and wait until kdump fisnihes + Backend.getInstance() + .getResourceManager() + .RunVdsCommand(VDSCommandType.SetVdsStatus, + new SetVdsStatusVDSCommandParameters(getVdsId(), VDSStatus.Reboot)); + + while (kdumpStatus.getStatus() != KdumpFlowStatus.FINISHED) { + ThreadUtils.sleep(interval); + kdumpStatus = dbf.getVdsKdumpStatusDao().get(getVdsId()); + } + + AuditLogableBase base = new AuditLogableBase(); + base.setVds(getVds()); + AuditLogDirector.log(base, AuditLogType.KDUMP_FLOW_FINISHED_ON_VDS); + + Backend.getInstance() + .getResourceManager() + .RunVdsCommand(VDSCommandType.SetVdsStatus, + new SetVdsStatusVDSCommandParameters(getVdsId(), VDSStatus.Connecting)); + + getReturnValue().setSucceeded(true); + } +} 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 cfdbc5b..7bf8f79 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 @@ -5,11 +5,13 @@ import org.apache.commons.lang.ObjectUtils; import org.ovirt.engine.core.bll.job.ExecutionContext; +import org.ovirt.engine.core.bll.job.ExecutionHandler; import org.ovirt.engine.core.common.AuditLogType; import org.ovirt.engine.core.common.VdcObjectType; import org.ovirt.engine.core.common.action.FenceVdsActionParameters; import org.ovirt.engine.core.common.action.SetStoragePoolStatusParameters; import org.ovirt.engine.core.common.action.VdcActionType; +import org.ovirt.engine.core.common.action.VdcReturnValueBase; import org.ovirt.engine.core.common.businessentities.StoragePoolStatus; import org.ovirt.engine.core.common.businessentities.VM; import org.ovirt.engine.core.common.businessentities.VMStatus; @@ -64,6 +66,17 @@ boolean shouldBeFenced = validator.shouldVdsBeFenced(); if (shouldBeFenced) { getParameters().setParentCommand(VdcActionType.VdsNotRespondingTreatment); + VdcReturnValueBase retVal = + Backend.getInstance().runInternalAction(VdcActionType.VdsKdumpDetection, + getParameters(), + ExecutionHandler.createInternalJobContext()); + + if (retVal.getSucceeded()) { + // kdump on host detected and finished successfully, stop hard fencing execution + getReturnValue().setSucceeded(true); + return; + } + // Make sure that the StopVdsCommand that runs by the RestartVds // don't write over our job, and disrupt marking the job status correctly ExecutionContext ec = (ExecutionContext) ObjectUtils.clone(this.getExecutionContext()); 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 515c87d..aaf53ca 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 @@ -110,6 +110,9 @@ // Proxy host selection PROXY_HOST_SELECTION(605), + KDUMP_FLOW_DETECTED_ON_VDS(613), + KDUMP_FLOW_FINISHED_ON_VDS(614), + HOST_REFRESHED_CAPABILITIES(606), HOST_REFRESH_CAPABILITIES_FAILED(607, AuditLogSeverity.ERROR), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java index 7efb946..f17cb13 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java @@ -82,6 +82,7 @@ UpgradeOvirtNodeInternal(129, QuotaDependency.NONE), InstallVds(130, ActionGroup.EDIT_HOST_CONFIGURATION, false, QuotaDependency.NONE), UpgradeOvirtNode(131, ActionGroup.EDIT_HOST_CONFIGURATION, false, QuotaDependency.NONE), + VdsKdumpDetection(132, QuotaDependency.NONE), // Network UpdateNetworkToVdsInterface(149, ActionGroup.CONFIGURE_HOST_NETWORK, QuotaDependency.NONE), 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 9210046..a946171 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties @@ -824,3 +824,5 @@ ISCSI_BOND_REMOVE_SUCCESS=iSCSI bond '${IscsiBondName}' was removed from Data Center '${StoragePoolName}' ISCSI_BOND_REMOVE_FAILED=Failed to remove iSCSI bond '${IscsiBondName}' from Data Center '${StoragePoolName}' +KDUMP_FLOW_DETECTED_ON_VDS=Kdump flow detected on host '${VdsName}'. +KDUMP_FLOW_FINISHED_ON_VDS=Kdump flow finished on host '${VdsName}'. diff --git a/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties b/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties index 1627af2..ed4e764 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/ExecutionMessages.properties @@ -112,6 +112,7 @@ job.ExportRepoImage=Exporting Disk ${DiskAlias} from domain ${Storage} job.SshSoftFencing=Executing SSH Soft Fencing on host ${VDS} job.RemoveDiskSnapshots=Removing Disks from Snapshot(s) ${Snapshots} of VM ${VM} +job.VdsKdumpDetection=Detecting kdump flow on host ${VDS} # Step types step.VALIDATING=Validating -- To view, visit http://gerrit.ovirt.org/28072 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I18145bc5814dc0b97b8ed6593f0c76473285ae16 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