Hello Yaniv Bronhaim,

I'd like you to do a code review.  Please visit

    http://gerrit.ovirt.org/18633

to review the following change.

Change subject: backend: Fixing log print when vdsm version is not supported in 
cluster
......................................................................

backend: Fixing log print when vdsm version is not supported in cluster

When adding new host we verify its vdsm version and cluster
compatibility as part of HandleVdsVersionCommand. During that we
printed the same message for both compatibilities issue (vdsm version
and cluster level support). This patch separates the validation part with
two different prints.

Change-Id: Iacfb3875a0617f978b4453769a0b1c5704282fa5
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=974101
Signed-off-by: Yaniv Bronhaim <ybron...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HandleVdsVersionCommand.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/dal/src/main/java/org/ovirt/engine/core/dal/dbbroker/auditloghandling/AuditLogDirector.java
M 
backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
6 files changed, 29 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/33/18633/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HandleVdsVersionCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HandleVdsVersionCommand.java
index 77bad07..404ec21 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HandleVdsVersionCommand.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/HandleVdsVersionCommand.java
@@ -1,17 +1,15 @@
 package org.ovirt.engine.core.bll;
 
-import static 
org.ovirt.engine.core.common.businessentities.NonOperationalReason.VERSION_INCOMPATIBLE_WITH_CLUSTER;
-
 import java.util.HashMap;
 import java.util.HashSet;
 import java.util.Map;
 
-import org.apache.commons.lang.StringUtils;
 import org.ovirt.engine.core.bll.job.ExecutionHandler;
 import org.ovirt.engine.core.bll.utils.VersionSupport;
 import org.ovirt.engine.core.common.action.SetNonOperationalVdsParameters;
 import org.ovirt.engine.core.common.action.VdcActionType;
 import org.ovirt.engine.core.common.action.VdsActionParameters;
+import org.ovirt.engine.core.common.businessentities.NonOperationalReason;
 import org.ovirt.engine.core.common.businessentities.VDS;
 import org.ovirt.engine.core.common.businessentities.VDSGroup;
 import org.ovirt.engine.core.common.businessentities.VDSStatus;
@@ -50,29 +48,31 @@
         // check that vdc support vds OR vds support vdc
         RpmVersion vdsVersion = vds.getVersion();
         Version vdsmVersion = new 
Version(vdsVersion.getMajor(),vdsVersion.getMinor());
-        boolean vdsmVersionSupported =
-                Config.<HashSet<Version>> 
GetValue(ConfigValues.SupportedVDSMVersions).contains(vdsmVersion);
-        if (!vdsmVersionSupported && 
!StringUtils.isEmpty(vds.getSupportedEngines())) {
-            try {
-                vdsmVersionSupported = 
vds.getSupportedENGINESVersionsSet().contains(partialVdcVersion);
-            } catch (RuntimeException e) {
-                log.error(e.getMessage());
-            }
-        }
 
         // move to non operational if vds-vdc version not supported OR cluster
         // version is not supported
-        if (!vdsmVersionSupported
-                || 
!VersionSupport.checkClusterVersionSupported(cluster.getcompatibility_version(),
 vds)) {
-            Map<String, String> customLogValues = new HashMap<String, 
String>();
-            customLogValues.put("CompatibilityVersion", 
cluster.getcompatibility_version().toString());
-            customLogValues.put("VdsSupportedVersions", 
vds.getSupportedClusterLevels());
-            SetNonOperationalVdsParameters tempVar = new 
SetNonOperationalVdsParameters(getVdsId(),
-                    VERSION_INCOMPATIBLE_WITH_CLUSTER,
-                    customLogValues);
-            tempVar.setSaveToDb(true);
-            
Backend.getInstance().runInternalAction(VdcActionType.SetNonOperationalVds, 
tempVar,  ExecutionHandler.createInternalJobContext());
+        if (!Config.<HashSet<Version>> 
GetValue(ConfigValues.SupportedVDSMVersions).contains(vdsmVersion)) {
+            
reportNonOperationReason(NonOperationalReason.VERSION_INCOMPATIBLE_WITH_CLUSTER,
+                                     Config.<HashSet<Version>> 
GetValue(ConfigValues.SupportedVDSMVersions).toString(),
+                                     vdsmVersion.toString());
+        }
+        else if 
(!VersionSupport.checkClusterVersionSupported(cluster.getcompatibility_version(),
 vds)) {
+            
reportNonOperationReason(NonOperationalReason.CLUSTER_VERSION_INCOMPATIBLE_WITH_CLUSTER,
+                                     
cluster.getcompatibility_version().toString(),
+                                     
vds.getSupportedClusterLevels().toString());
         }
         setSucceeded(true);
     }
+
+    private void reportNonOperationReason(NonOperationalReason reason, String 
compatibleVersions,
+                                          String vdsSupportedVersions) {
+        Map<String, String> customLogValues = new HashMap<>();
+        customLogValues.put("CompatibilityVersion", compatibleVersions);
+        customLogValues.put("VdsSupportedVersions", vdsSupportedVersions);
+        SetNonOperationalVdsParameters tempVar = new 
SetNonOperationalVdsParameters(getVdsId(),
+                reason,
+                customLogValues);
+        tempVar.setSaveToDb(true);
+        
Backend.getInstance().runInternalAction(VdcActionType.SetNonOperationalVds, 
tempVar,  ExecutionHandler.createInternalJobContext());
+    }
 }
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 c8a1897..7d6b710 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
@@ -110,6 +110,8 @@
             return AuditLogType.VDS_RUN_IN_NO_KVM_MODE;
         case VERSION_INCOMPATIBLE_WITH_CLUSTER:
             return AuditLogType.VDS_VERSION_NOT_SUPPORTED_FOR_CLUSTER;
+        case CLUSTER_VERSION_INCOMPATIBLE_WITH_CLUSTER:
+            return AuditLogType.VDS_CLUSTER_VERSION_NOT_SUPPORTED;
         case VM_NETWORK_IS_BRIDGELESS:
             return 
AuditLogType.VDS_SET_NON_OPERATIONAL_VM_NETWORK_IS_BRIDGELESS;
         case GLUSTER_COMMAND_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 202280f..bf37cd7 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
@@ -372,6 +372,7 @@
     VM_NOT_RESPONDING(126),
     VDS_RUN_IN_NO_KVM_MODE(127),
     VDS_VERSION_NOT_SUPPORTED_FOR_CLUSTER(141),
+    VDS_CLUSTER_VERSION_NOT_SUPPORTED(154),
     VM_CLEARED(129),
     VM_PAUSED_ENOSPC(138),
     VM_PAUSED_ERROR(139),
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 c7926ba..ef4c7b8 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
@@ -19,6 +19,7 @@
     EMULATED_MACHINES_INCOMPATIBLE_WITH_CLUSTER(11),
     UNTRUSTED(12),
     UNINITIALIZED(13),
+    CLUSTER_VERSION_INCOMPATIBLE_WITH_CLUSTER(14),
     ;
 
     private final int value;
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 f3641de..80cad02 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
@@ -271,6 +271,7 @@
         
severities.put(AuditLogType.VDS_ALERT_SECONDARY_AGENT_USED_FOR_FENCE_OPERATION, 
AuditLogSeverity.ALERT);
         severities.put(AuditLogType.VDS_RUN_IN_NO_KVM_MODE, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.VDS_VERSION_NOT_SUPPORTED_FOR_CLUSTER, 
AuditLogSeverity.ERROR);
+        severities.put(AuditLogType.VDS_CLUSTER_VERSION_NOT_SUPPORTED, 
AuditLogSeverity.ERROR);
         severities.put(AuditLogType.VDS_CPU_LOWER_THAN_CLUSTER, 
AuditLogSeverity.WARNING);
         severities.put(AuditLogType.CPU_FLAGS_NX_IS_MISSING, 
AuditLogSeverity.WARNING);
         severities.put(AuditLogType.VDS_CPU_RETRIEVE_FAILED, 
AuditLogSeverity.WARNING);
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 1cf170e..2aebc63 100644
--- 
a/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
+++ 
b/backend/manager/modules/dal/src/main/resources/bundles/AuditLogMessages.properties
@@ -346,7 +346,8 @@
 USER_FAILED_CLEAR_UNKNOWN_VMS=Failed to clear VMs' status on Non Responsive 
Host ${VdsName}. (User: ${UserName}).
 CERTIFICATE_FILE_NOT_FOUND=Could not find oVirt Engine Certificate file.
 VDS_RUN_IN_NO_KVM_MODE=Host ${VdsName} running without virtualization hardware 
acceleration
-VDS_VERSION_NOT_SUPPORTED_FOR_CLUSTER=Host ${VdsName} is compatible with 
versions (${VdsSupportedVersions}) and cannot join Cluster ${VdsGroupName} 
which is set to version ${CompatibilityVersion}.
+VDS_VERSION_NOT_SUPPORTED_FOR_CLUSTER=Host ${VdsName} is installed with VDSM 
version (${VdsSupportedVersions}) and cannot join cluster ${VdsGroupName} which 
is compatible with VDSM versions ${CompatibilityVersion}.
+VDS_CLUSTER_VERSION_NOT_SUPPORTED=Host ${VdsName} is compatible with versions 
(${VdsSupportedVersions}) and cannot join Cluster ${VdsGroupName} which is set 
to version ${CompatibilityVersion}.
 RUN_VM_FAILED=Cannot run VM ${VmName} on Host ${VdsName}. Error: ${ErrMsg}
 USER_ADD_PERMISSION=User/Group ${SubjectName} was granted permission for Role 
${RoleName} on ${VdcObjectType} ${VdcObjectName}, by ${UserName}.
 USER_ADD_PERMISSION_FAILED=User ${UserName} failed to grant permission for 
Role ${RoleName} on ${VdcObjectType} ${VdcObjectName} to User/Group 
${SubjectName}.


-- 
To view, visit http://gerrit.ovirt.org/18633
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Iacfb3875a0617f978b4453769a0b1c5704282fa5
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.3
Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com>
Gerrit-Reviewer: Yaniv Bronhaim <ybron...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to