Kanagaraj M has uploaded a new change for review. Change subject: engine: fetch gluster host uuid during InitVdsOnUp ......................................................................
engine: fetch gluster host uuid during InitVdsOnUp When a gluster host comes up, if gluster host uuid of the host is empty it will be fetched and stored in the database. And the host will be moved to NonOperational if the gluster host uuid is not found in db as well as failed to retrieve the same from vdsm. A new NonOperationReason is added and also the corresponding entries to AuditLog as well. Change-Id: Ied8e8b006adc5722cd70ee19d75a4b6f783d5f44 Signed-off-by: Kanagaraj M <kmayi...@redhat.com> --- 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/SetNonOperationalVdsCommand.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/businessentities/NonOperationalReason.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java M backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/gluster/GlusterFeatureSupported.java M backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java M backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties 8 files changed, 103 insertions(+), 38 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/66/14166/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 f1f2172..d69d94f 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 @@ -25,6 +25,7 @@ import org.ovirt.engine.core.common.businessentities.VdsSpmStatus; import org.ovirt.engine.core.common.businessentities.storage_pool; import org.ovirt.engine.core.common.businessentities.gluster.GlusterServerInfo; +import org.ovirt.engine.core.common.businessentities.gluster.VdsGluster; import org.ovirt.engine.core.common.businessentities.network.VdsNetworkInterface; import org.ovirt.engine.core.common.errors.VdcBLLException; import org.ovirt.engine.core.common.errors.VdcBllErrors; @@ -32,6 +33,7 @@ import org.ovirt.engine.core.common.eventqueue.EventQueue; 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.vdscommands.ConnectStoragePoolVDSCommandParameters; import org.ovirt.engine.core.common.vdscommands.VDSCommandType; import org.ovirt.engine.core.common.vdscommands.VDSReturnValue; @@ -43,6 +45,7 @@ import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AlertDirector; import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogDirector; import org.ovirt.engine.core.dal.dbbroker.auditloghandling.AuditLogableBase; +import org.ovirt.engine.core.dao.gluster.VdsGlusterDao; import org.ovirt.engine.core.dao.network.InterfaceDao; import org.ovirt.engine.core.utils.ejb.BeanProxyType; import org.ovirt.engine.core.utils.ejb.BeanType; @@ -61,7 +64,7 @@ private boolean _fenceSucceeded = true; private boolean _vdsProxyFound; private boolean _connectStorageSucceeded, _connectPoolSucceeded; - private boolean _glusterPeerListSucceeded, _glusterPeerProbeSucceeded; + private boolean _glusterHostUuidFound, _glusterPeerListSucceeded, _glusterPeerProbeSucceeded; private FenceStatusReturnValue _fenceStatusReturnValue; public InitVdsOnUpCommand(HostStoragePoolParametersBase parameters) { @@ -78,7 +81,7 @@ } if (vdsGroup.supportsGlusterService()) { - setSucceeded(initGlusterPeerProcess()); + setSucceeded(initGlusterHost()); } } @@ -233,42 +236,55 @@ public AuditLogType getAuditLogTypeValue() { AuditLogType type = AuditLogType.UNASSIGNED; - if(!getVdsGroup().supportsVirtService()) { - if (getVdsGroup().supportsGlusterService()) { - if (!_glusterPeerListSucceeded) { - type = AuditLogType.GLUSTER_SERVERS_LIST_FAILED; - } else if (!_glusterPeerProbeSucceeded) { - type = AuditLogType.GLUSTER_SERVER_ADD_FAILED; + if (getVdsGroup().supportsGlusterService()) { + if (!_glusterHostUuidFound) { + type = AuditLogType.GLUSTER_HOST_UUID_NOT_FOUND; + } else if (!_glusterPeerListSucceeded) { + type = AuditLogType.GLUSTER_SERVERS_LIST_FAILED; + } else if (!_glusterPeerProbeSucceeded) { + type = AuditLogType.GLUSTER_SERVER_ADD_FAILED; + } + } + + if (type == AuditLogType.UNASSIGNED && getVdsGroup().supportsVirtService()) { + if (!_connectStorageSucceeded) { + type = AuditLogType.CONNECT_STORAGE_SERVERS_FAILED; + } else if (!_connectPoolSucceeded) { + type = AuditLogType.CONNECT_STORAGE_POOL_FAILED; + } else if (getVds().getpm_enabled() && _fenceSucceeded) { + type = AuditLogType.VDS_FENCE_STATUS; + } else if (getVds().getpm_enabled() && !_fenceSucceeded) { + type = AuditLogType.VDS_FENCE_STATUS_FAILED; + } + + // PM alerts + AuditLogableBase logable = new AuditLogableBase(getVds().getId()); + if (getVds().getpm_enabled()) { + if (!_vdsProxyFound) { + logable.addCustomValue("Reason", + AuditLogDirector.getMessage(AuditLogType.VDS_ALERT_FENCE_NO_PROXY_HOST)); + AlertDirector.Alert(logable, AuditLogType.VDS_ALERT_FENCE_TEST_FAILED); + } else if (!_fenceStatusReturnValue.getIsSucceeded()) { + logable.addCustomValue("Reason", _fenceStatusReturnValue.getMessage()); + AlertDirector.Alert(logable, AuditLogType.VDS_ALERT_FENCE_TEST_FAILED); } + } else { + AlertDirector.Alert(logable, AuditLogType.VDS_ALERT_FENCE_IS_NOT_CONFIGURED); } - return type; } - if (!_connectStorageSucceeded) { - type = AuditLogType.CONNECT_STORAGE_SERVERS_FAILED; - } else if (!_connectPoolSucceeded) { - type = AuditLogType.CONNECT_STORAGE_POOL_FAILED; - } else if (getVds().getpm_enabled() && _fenceSucceeded) { - type = AuditLogType.VDS_FENCE_STATUS; - } else if (getVds().getpm_enabled() && !_fenceSucceeded) { - type = AuditLogType.VDS_FENCE_STATUS_FAILED; - } - - // PM alerts - AuditLogableBase logable = new AuditLogableBase(getVds().getId()); - if (getVds().getpm_enabled()) { - if (!_vdsProxyFound) { - logable.addCustomValue("Reason", - AuditLogDirector.getMessage(AuditLogType.VDS_ALERT_FENCE_NO_PROXY_HOST)); - AlertDirector.Alert(logable, AuditLogType.VDS_ALERT_FENCE_TEST_FAILED); - } else if (!_fenceStatusReturnValue.getIsSucceeded()) { - logable.addCustomValue("Reason", _fenceStatusReturnValue.getMessage()); - AlertDirector.Alert(logable, AuditLogType.VDS_ALERT_FENCE_TEST_FAILED); - } - } else { - AlertDirector.Alert(logable, AuditLogType.VDS_ALERT_FENCE_IS_NOT_CONFIGURED); - } return type; + } + + private boolean initGlusterHost() { + _glusterHostUuidFound = true; + if (GlusterFeatureSupported.glusterHostUuidSupported(getVdsGroup().getcompatibility_version())) { + if (!saveGlusterHostUuid()) { + _glusterHostUuidFound = false; + setNonOperational(NonOperationalReason.GLUSTER_HOST_UUID_NOT_FOUND, null); + } + } + return _glusterHostUuidFound && initGlusterPeerProcess(); } private boolean initGlusterPeerProcess() { @@ -307,19 +323,50 @@ } private boolean hostExists(List<GlusterServerInfo> glusterServers, VDS server) { - for (GlusterServerInfo glusterServer : glusterServers) { - if (glusterServer.getHostnameOrIp().equals(server.getHostName())) { - return true; + if (GlusterFeatureSupported.glusterHostUuidSupported(getVdsGroup().getcompatibility_version())) { + VdsGluster vdsGluster = DbFacade.getInstance().getVdsGlusterDao().getByVdsId(getVds().getId()); + if (vdsGluster != null) { + for (GlusterServerInfo glusterServer : glusterServers) { + if (glusterServer.getUuid().equals(vdsGluster.getHostUuid())) { + return true; + } + } } - for (VdsNetworkInterface vdsNwInterface : getVdsInterfaces(server.getId())) { - if (glusterServer.getHostnameOrIp().equals(vdsNwInterface.getAddress())) { + } + else { + for (GlusterServerInfo glusterServer : glusterServers) { + if (glusterServer.getHostnameOrIp().equals(server.getHostName())) { return true; + } + for (VdsNetworkInterface vdsNwInterface : getVdsInterfaces(server.getId())) { + if (glusterServer.getHostnameOrIp().equals(vdsNwInterface.getAddress())) { + return true; + } } } } return false; } + private boolean saveGlusterHostUuid() { + VdsGlusterDao vdsGlusterDao = DbFacade.getInstance().getVdsGlusterDao(); + VdsGluster vdsGluster = vdsGlusterDao.getByVdsId(getVds().getId()); + if (vdsGluster == null) { + VDSReturnValue returnValue = runVdsCommand(VDSCommandType.GetGlusterHostUUID, + new VdsIdVDSCommandParametersBase(getVds().getId())); + if (returnValue.getSucceeded() && returnValue.getReturnValue() != null) { + vdsGluster = new VdsGluster(); + vdsGluster.setVdsId(getVds().getId()); + vdsGluster.setHostUuid((Guid) returnValue.getReturnValue()); + vdsGlusterDao.save(vdsGluster); + } + else { + return false; + } + } + return true; + } + public InterfaceDao getInterfaceDAO() { return getDbFacade().getInterfaceDao(); } diff --git a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetNonOperationalVdsCommand.java b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetNonOperationalVdsCommand.java index 6b797e7..0198a36 100644 --- a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetNonOperationalVdsCommand.java +++ b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/SetNonOperationalVdsCommand.java @@ -114,6 +114,8 @@ return AuditLogType.VDS_SET_NON_OPERATIONAL_VM_NETWORK_IS_BRIDGELESS; case GLUSTER_COMMAND_FAILED: return AuditLogType.GLUSTER_COMMAND_FAILED; + case GLUSTER_HOST_UUID_NOT_FOUND: + return AuditLogType.GLUSTER_HOST_UUID_NOT_FOUND; default: return (getSucceeded()) ? AuditLogType.VDS_SET_NONOPERATIONAL : AuditLogType.VDS_SET_NONOPERATIONAL_FAILED; } 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 1cbd33e..738dda9 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 @@ -245,6 +245,7 @@ GLUSTER_HOOK_DISABLE(4045), GLUSTER_HOOK_DISABLE_FAILED(4046), GLUSTER_HOOK_DISABLE_PARTIAL(4047), + GLUSTER_HOST_UUID_NOT_FOUND(4048), USER_VDS_RESTART(41), USER_FAILED_VDS_RESTART(107), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java index b2536b8..f10f89c 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/businessentities/NonOperationalReason.java @@ -15,6 +15,7 @@ TIMEOUT_RECOVERING_FROM_CRASH(7), VM_NETWORK_IS_BRIDGELESS(8), GLUSTER_COMMAND_FAILED(9), + GLUSTER_HOST_UUID_NOT_FOUND(10), ; private final int value; diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java index 3422353..ca1af9b 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/config/ConfigValues.java @@ -1348,6 +1348,10 @@ @DefaultValueAttribute("true") GlusterRefreshHeavyWeight(423), + @TypeConverterAttribute(Boolean.class) + @DefaultValueAttribute("true") + GlusterHostUUIDSupport(424), + @TypeConverterAttribute(String.class) @DefaultValueAttribute("Auto") ClientConsoleModeDefault(501), diff --git a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/gluster/GlusterFeatureSupported.java b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/gluster/GlusterFeatureSupported.java index 5d56a2d..699a0ac 100644 --- a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/gluster/GlusterFeatureSupported.java +++ b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/gluster/GlusterFeatureSupported.java @@ -28,4 +28,12 @@ return supportedInConfig(ConfigValues.GlusterRefreshHeavyWeight, version); } + /** + * @param version + * Compatibility version to check for. + * @return <code>true</code> if gluster host UUID is supported, <code>false</code> if it's not. + */ + public static boolean glusterHostUuidSupported(Version version) { + return supportedInConfig(ConfigValues.GlusterHostUUIDSupport, version); + } } diff --git a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java index cf9b251..9bd1f66 100644 --- a/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java +++ b/backend/manager/modules/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java @@ -107,6 +107,7 @@ severities.put(AuditLogType.GLUSTER_HOOK_DISABLE, AuditLogSeverity.NORMAL); severities.put(AuditLogType.GLUSTER_HOOK_DISABLE_PARTIAL, AuditLogSeverity.WARNING); severities.put(AuditLogType.GLUSTER_HOOK_DISABLE_FAILED, AuditLogSeverity.ERROR); + severities.put(AuditLogType.GLUSTER_HOST_UUID_NOT_FOUND, AuditLogSeverity.ERROR); } private static void initDefaultSeverities() { 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 e65fd10..8d8f81e 100644 --- a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties +++ b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties @@ -597,4 +597,5 @@ GLUSTER_HOOK_DISABLE=Gluster Hook ${GlusterHookName} disabled on cluster ${VdsGroupName}. GLUSTER_HOOK_DISABLE_FAILED=Failed to disable Gluster Hook ${GlusterHookName} on cluster ${VdsGroupName}. ${FailureMessage} GLUSTER_HOOK_DISABLE_PARTIAL=Gluster Hook ${GlusterHookName} disabled on some of the servers on cluster ${VdsGroupName}. ${FailureMessage} +GLUSTER_HOST_UUID_NOT_FOUND=Could not find gluster uuid of server ${VdsName} on Cluster ${VdsGroupName}. -- To view, visit http://gerrit.ovirt.org/14166 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Ied8e8b006adc5722cd70ee19d75a4b6f783d5f44 Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Kanagaraj M <kmayi...@redhat.com> _______________________________________________ Engine-patches mailing list Engine-patches@ovirt.org http://lists.ovirt.org/mailman/listinfo/engine-patches