Tal Nisan has uploaded a new change for review. Change subject: core: Report unreachable domain names when setting host as non operational ......................................................................
core: Report unreachable domain names when setting host as non operational When setting a host as non operation because an error reaching one or more storage domain, the audit log will now report the names of the unreachable storage domains Signed-off-by: Tal Nisan <[email protected]> https://bugzilla.redhat.com/1079583 Change-Id: I1dc385da76b6a4b0776d783c0df33fa737d206c0 --- M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/InitVdsOnUpCommand.java M backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommand.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/eventqueue/EventResult.java M backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties M backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsBrokerCommand.java 5 files changed, 50 insertions(+), 19 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/59/28859/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 1989350..2bd773c 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 @@ -1,7 +1,6 @@ package org.ovirt.engine.core.bll; import java.util.ArrayList; -import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; @@ -45,6 +44,7 @@ import org.ovirt.engine.core.common.eventqueue.EventResult; import org.ovirt.engine.core.common.eventqueue.EventType; import org.ovirt.engine.core.common.gluster.GlusterFeatureSupported; +import org.ovirt.engine.core.common.utils.Pair; import org.ovirt.engine.core.common.vdscommands.ConnectStoragePoolVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.MomPolicyVDSParameters; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; @@ -77,6 +77,7 @@ public class InitVdsOnUpCommand extends StorageHandlingCommandBase<HostStoragePoolParametersBase> { private boolean fenceSucceeded = true; private boolean vdsProxyFound; + private List<StorageDomainStatic> problematicDomains; private boolean connectPoolSucceeded; private boolean glusterHostUuidFound, glusterPeerListSucceeded, glusterPeerProbeSucceeded; private FenceStatusReturnValue fenceStatusReturnValue; @@ -152,7 +153,18 @@ processStoragePoolStatus(); runUpdateMomPolicy(getVdsGroup(), getVds()); } else { - Map<String, String> customLogValues = Collections.singletonMap("StoragePoolName", getStoragePoolName()); + Map<String, String> customLogValues = new HashMap<>(); + customLogValues.put("StoragePoolName", getStoragePoolName()); + if (problematicDomains != null) { + StringBuilder domainNames = new StringBuilder(); + for (StorageDomainStatic domain : problematicDomains) { + if (domainNames.length() > 0) { + domainNames.append(", "); + } + domainNames.append(domain.getStorageName()); + } + customLogValues.put("StorageDomainNames", domainNames.toString()); + } setNonOperational(NonOperationalReason.STORAGE_DOMAIN_UNREACHABLE, customLogValues); return false; } @@ -200,8 +212,12 @@ } else { ConnectHostToStoragePoolServersParameters params = new ConnectHostToStoragePoolServersParameters(getStoragePool(), getVds()); Backend.getInstance().runInternalAction(VdcActionType.ConnectHostToStoragePoolServers, params); - returnValue = connectHostToPool(); + EventResult connectResult = connectHostToPool(); + returnValue = connectResult == null ? false : connectResult.isSuccess(); connectPoolSucceeded = returnValue; + if (!returnValue) { + problematicDomains = (List<StorageDomainStatic>) connectResult.getResultData(); + } } return returnValue; } @@ -213,7 +229,7 @@ * we will try to run reconstruct * @return */ - private boolean connectHostToPool() { + private EventResult connectHostToPool() { final VDS vds = getVds(); EventResult result = ((EventQueue) EjbUtils.findBean(BeanType.EVENTQUEUE_MANAGER, BeanProxyType.LOCAL)).submitEventSync(new Event(getStoragePool().getId(), @@ -224,10 +240,7 @@ return runConnectHostToPoolEvent(getStoragePool().getId(), vds); } }); - if (result != null) { - return result.isSuccess(); - } - return false; + return result; } private EventResult runConnectHostToPoolEvent(final Guid storagePoolId, final VDS vds) { @@ -263,8 +276,10 @@ } if (result.isSuccess()) { - result.setSuccess(proceedVdsStats(!masterDomainInactiveOrUnknown)); + Pair<Boolean, List<StorageDomainStatic>> vdsStatsResults = proceedVdsStats(!masterDomainInactiveOrUnknown); + result.setSuccess(vdsStatsResults.getFirst()); if (!result.isSuccess()) { + result.setResultData(vdsStatsResults.getSecond()); AuditLogDirector.log(new AuditLogableBase(getVdsId()), AuditLogType.VDS_STORAGE_VDS_STATS_FAILED); } @@ -288,8 +303,8 @@ return returnValue; } - protected boolean proceedVdsStats(boolean shouldCheckReportedDomains) { - boolean returnValue = true; + private Pair<Boolean, List<StorageDomainStatic>> proceedVdsStats(boolean shouldCheckReportedDomains) { + Pair<Boolean, List<StorageDomainStatic>> returnValue = new Pair<>(true, null); try { runVdsCommand(VDSCommandType.GetStats, new VdsIdAndVdsVDSCommandParametersBase(getVds())); if (shouldCheckReportedDomains) { @@ -303,7 +318,11 @@ getStoragePool().getName(), getVds().getName()); if (domainInfo == null || domainInfo.getStorageDomainType().isDataDomain()) { - returnValue = false; + returnValue.setFirst(false); + if (returnValue.getSecond() == null) { + returnValue.setSecond(new ArrayList<StorageDomainStatic>()); + } + returnValue.getSecond().add(domainInfo); } } } @@ -311,7 +330,7 @@ log.errorFormat("Could not get Host statistics for Host {0}, Error is {1}", getVds().getName(), e); - returnValue = false; + returnValue.setFirst(false); } return returnValue; } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommand.java index 02746de..0fd3f3c 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/storage/ActivateStorageDomainCommand.java @@ -127,8 +127,9 @@ ); for (Guid vdsId : vdsIdsToSetNonOperational) { + Map<String, String> customLogValues = Collections.singletonMap("StorageDomainNames", getStorageDomainName()); SetNonOperationalVdsParameters tempVar = - new SetNonOperationalVdsParameters(vdsId, STORAGE_DOMAIN_UNREACHABLE); + new SetNonOperationalVdsParameters(vdsId, STORAGE_DOMAIN_UNREACHABLE, customLogValues); tempVar.setStorageDomainId(getStorageDomain().getId()); tempVar.setTransactionScopeOption(TransactionScopeOption.RequiresNew); getBackend().runInternalAction(VdcActionType.SetNonOperationalVds, diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/eventqueue/EventResult.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/eventqueue/EventResult.java index bfb8b82..d14f407 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/eventqueue/EventResult.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/eventqueue/EventResult.java @@ -4,6 +4,7 @@ private boolean success; private EventType eventType; + private Object resultData; public EventResult(boolean success, EventType eventType) { this.success = success; @@ -26,4 +27,11 @@ this.success = success; } + public Object getResultData() { + return resultData; + } + + public void setResultData(Object resultData) { + this.resultData = resultData; + } } 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 772d799..b41d333 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties @@ -549,8 +549,8 @@ REMOVE_VNIC_PROFILE_FAILED=Failed to remove VM network interface profile ${VnicProfileName} from network ${NetworkName} in Data Center: ${DataCenterName}. (User: ${UserName}) SYSTEM_DEACTIVATED_STORAGE_DOMAIN=Storage Domain ${StorageDomainName} (Data Center ${StoragePoolName}) was deactivated by system because it's not visible by any of the hosts. SYSTEM_DEACTIVATE_STORAGE_DOMAIN_FAILED=Failed to deactivate Storage Domain ${StorageDomainName} (Data Center ${StoragePoolName}). -VDS_SET_NONOPERATIONAL_DOMAIN=Host ${VdsName} cannot access one of the Storage Domains attached to the Data Center ${StoragePoolName}. Setting Host state to Non-Operational. -VDS_SET_NONOPERATIONAL_DOMAIN_FAILED=Host ${VdsName} cannot access one of the Storage Domains attached to the Data Center ${StoragePoolName}. Failed to set Host state to Non-Operational. +VDS_SET_NONOPERATIONAL_DOMAIN=Host ${VdsName} cannot access the Storage Domain(s) ${StorageDomainNames} attached to the Data Center ${StoragePoolName}. Setting Host state to Non-Operational. +VDS_SET_NONOPERATIONAL_DOMAIN_FAILED=Host ${VdsName} cannot access the Storage Domain(s) ${StorageDomainNames} attached to the Data Center ${StoragePoolName}. Failed to set Host state to Non-Operational. VDS_DOMAIN_DELAY_INTERVAL=Storage domain ${StorageDomainName} experienced a high latency of ${Delay} seconds from host ${VdsName}. This may cause performance and functional issues. Please consult your Storage Administrator. USER_EXTENDED_STORAGE_DOMAIN=Storage ${StorageDomainName} has been extended by ${UserName}. Please wait for refresh. USER_EXTENDED_STORAGE_DOMAIN_FAILED=Failed to extend Storage Domain ${StorageDomainName}. (User: ${UserName}) diff --git a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsBrokerCommand.java b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsBrokerCommand.java index 0e99dcf..0e0cd48 100644 --- a/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsBrokerCommand.java +++ b/backend/manager/modules/vdsbroker/src/main/java/org/ovirt/engine/core/vdsbroker/irsbroker/IrsBrokerCommand.java @@ -1365,7 +1365,7 @@ // is with the hosts // that did report on a problem with this domain. // (and not a problem with the domain itself). - StorageDomainStatic storageDomain = DbFacade.getInstance().getStorageDomainStaticDao().get(domainId); + final StorageDomainStatic storageDomain = DbFacade.getInstance().getStorageDomainStaticDao().get(domainId); String domainIdTuple = getDomainIdTuple(domainId); List<Guid> nonOpVdss = new ArrayList<Guid>(); if (vdssInProblem.size() > 0) { @@ -1395,8 +1395,11 @@ ResourceManager .getInstance() .getEventListener() - .vdsNonOperational(vdsId, NonOperationalReason.STORAGE_DOMAIN_UNREACHABLE, - true, domainId); + .vdsNonOperational(vdsId, + NonOperationalReason.STORAGE_DOMAIN_UNREACHABLE, + true, + domainId, + Collections.singletonMap("storageDomainNames", storageDomain.getStorageName())); } }); -- To view, visit http://gerrit.ovirt.org/28859 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I1dc385da76b6a4b0776d783c0df33fa737d206c0 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tal Nisan <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
