use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.
the class IrsProxy method reconstructMasterDomainNotInSync.
/**
* Reconstructs the master domain when the old domain is not in sync.
*
* @param storagePoolId
* The storage pool id.
* @param masterDomain
* The master domain.
* @param exceptionMessage
* The message of the exception to throw.
* @param logMessage
* The log message to write in the log.
*/
private void reconstructMasterDomainNotInSync(final Guid storagePoolId, final StorageDomainStatic masterDomain, final String exceptionMessage, final String logMessage) {
getEventQueue().submitEventSync(new Event(this.storagePoolId, masterDomain.getId(), null, EventType.RECONSTRUCT, "Reconstruct caused by failure to execute spm command"), () -> {
log.warn(logMessage);
AuditLogable logable = new AuditLogableImpl();
logable.setVdsId(currentVdsId);
logable.setVdsName(vdsStaticDao.get(currentVdsId).getName());
logable.setStorageDomainId(masterDomain.getId());
logable.setStorageDomainName(masterDomain.getName());
auditLogDirector.log(logable, AuditLogType.SYSTEM_MASTER_DOMAIN_NOT_IN_SYNC);
return getEventListener().masterDomainNotOperational(masterDomain.getId(), storagePoolId, false, true);
});
throw new IRSNoMasterDomainException(exceptionMessage);
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.
the class SingleAgentFenceActionExecutor method auditVerifyStatusRetryLimitExceeded.
protected void auditVerifyStatusRetryLimitExceeded(FenceActionType fenceAction) {
AuditLogable auditLogable = new AuditLogableImpl();
auditLogable.addCustomValue("Host", fencedHost.getName());
auditLogable.addCustomValue("Status", fenceAction.name().toLowerCase());
auditLogable.setVdsId(fencedHost.getId());
auditLogable.setVdsName(fencedHost.getName());
getAuditLogDirector().log(auditLogable, AuditLogType.VDS_ALERT_FENCE_STATUS_VERIFICATION_FAILED);
log.error("Failed to verify host '{}' status after {} action: have retried {} times with delay of {} seconds" + " between each retry.", fencedHost.getHostName(), fenceAction.name(), allowedWaitForStatusRetries, delayBetweenRetries);
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.
the class VdsNotRespondingTreatmentCommand method createAuditLogableForHost.
private AuditLogable createAuditLogableForHost(VDS vds) {
AuditLogable logable = new AuditLogableImpl();
logable.setVdsId(vds.getId());
logable.setVdsName(vds.getName());
logable.setClusterId(vds.getClusterId());
logable.setClusterName(vds.getClusterName());
logable.setRepeatable(true);
return logable;
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.
the class VdsNotRespondingTreatmentCommand method executeCommand.
/**
* Only fence the host if the VDS is down, otherwise it might have gone back up until this command was executed. If
* the VDS is not fenced then don't send an audit log event.
*/
@Override
protected void executeCommand() {
VDS host = getVds();
if (!previousHostedEngineHost.isPreviousHostId(host.getId()) && !fenceValidator.isStartupTimeoutPassed() && !host.isInFenceFlow()) {
log.error("Failed to run Fence script on vds '{}'.", getVdsName());
alertIfPowerManagementOperationSkipped();
// If fencing can't be done and the host is the SPM, set storage-pool to non-operational
if (host.getSpmStatus() != VdsSpmStatus.None) {
setStoragePoolNonOperational();
}
return;
}
setVds(null);
if (getVds() == null) {
setCommandShouldBeLogged(false);
log.info("Host '{}' ({}) not fenced since it doesn't exist anymore.", getVdsName(), getVdsId());
getReturnValue().setSucceeded(false);
return;
}
if (shouldFencingBeSkipped(getVds())) {
setSucceeded(false);
setCommandShouldBeLogged(false);
return;
}
boolean shouldBeFenced = getVds().shouldVdsBeFenced();
ActionReturnValue restartVdsResult = null;
if (shouldBeFenced) {
getParameters().setParentCommand(ActionType.VdsNotRespondingTreatment);
ActionReturnValue retVal;
retVal = runInternalAction(ActionType.SshSoftFencing, getParameters(), cloneContext().withoutExecutionContext());
if (retVal.getSucceeded()) {
// SSH Soft Fencing was successful and host is Up, stop non responding treatment
getReturnValue().setSucceeded(true);
setCommandShouldBeLogged(false);
return;
}
// proceed with non responding treatment only if PM action are allowed and PM enabled for host
if (!monitoringStrategyFactory.getMonitoringStrategyForVds(getVds()).isPowerManagementSupported() || !getVds().isPmEnabled()) {
setSucceeded(false);
setCommandShouldBeLogged(false);
return;
}
retVal = runInternalAction(ActionType.VdsKdumpDetection, getParameters(), cloneContext().withoutExecutionContext());
if (retVal.getSucceeded()) {
// kdump on host detected and finished successfully, stop hard fencing execution
getReturnValue().setSucceeded(true);
return;
}
// load cluster fencing policy
FencingPolicy fencingPolicy = clusterDao.get(getVds().getClusterId()).getFencingPolicy();
getParameters().setFencingPolicy(fencingPolicy);
waitUntilSkipFencingIfSDActiveAllowed(fencingPolicy.isSkipFencingIfSDActive());
restartVdsResult = runInternalAction(ActionType.RestartVds, getParameters(), cloneContext().withoutExecutionContext());
} else {
setCommandShouldBeLogged(false);
log.info("Host '{}' ({}) not fenced since it's status is ok, or it doesn't exist anymore.", getVdsName(), getVdsId());
}
if (restartVdsResult != null && restartVdsResult.<RestartVdsResult>getActionReturnValue() != null && restartVdsResult.<RestartVdsResult>getActionReturnValue().isSkippedDueToFencingPolicy()) {
// fencing was skipped, fire an alert and suppress standard command logging
AuditLogable alb = createAuditLogableForHost(getVds());
auditLogDirector.log(alb, AuditLogType.VDS_ALERT_NOT_RESTARTED_DUE_TO_POLICY);
setSucceeded(false);
setCommandShouldBeLogged(false);
} else {
getReturnValue().setSucceeded(shouldBeFenced);
}
}
use of org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogable in project ovirt-engine by oVirt.
the class BlockStorageDiscardFunctionalityHelper method logIfDisksWithIllegalPassDiscardExist.
public void logIfDisksWithIllegalPassDiscardExist(Guid vmId) {
Collection<DiskImage> disks = DisksFilter.filterImageDisks(diskDao.getAllForVm(vmId));
Collection<DiskVmElement> diskVmElements = diskVmElementDao.getAllForVm(vmId);
Map<Disk, DiskVmElement> diskToDiskVmElement = diskHandler.getDiskToDiskVmElementMap(disks, diskVmElements);
Map<Guid, Guid> diskIdToDestSdId = disks.stream().collect(Collectors.toMap(DiskImage::getId, diskImage -> diskImage.getStorageIds().get(0)));
MultipleDiskVmElementValidator multipleDiskVmElementValidator = new MultipleDiskVmElementValidator(diskToDiskVmElement);
Collection<Guid> disksWithoutSupportForPassDiscard = multipleDiskVmElementValidator.getDisksWithoutSupportForPassDiscard(diskIdToDestSdId);
if (!disksWithoutSupportForPassDiscard.isEmpty()) {
AuditLogable auditLog = new AuditLogableImpl();
auditLog.addCustomValue("DisksIds", disksWithoutSupportForPassDiscard.stream().map(Guid::toString).collect(Collectors.joining(", ")));
auditLogDirector.log(auditLog, AuditLogType.DISKS_WITH_ILLEGAL_PASS_DISCARD_EXIST);
}
}
Aggregations