From 99c776847036b5c9d975eab1aa596f106e66fe75 Mon Sep 17 00:00:00 2001 From: yodigos Date: Thu, 12 Sep 2024 11:24:27 +0300 Subject: [PATCH] feat: Fix version log (#1494) --- .../controllers/instrumentationdevice/common.go | 6 +++--- .../utils/versionsupport/java_support.go | 3 +-- .../versionsupport/language_version_support.go | 13 +++++++++---- .../versionsupport/language_version_support_test.go | 10 +++++----- 4 files changed, 18 insertions(+), 14 deletions(-) diff --git a/instrumentor/controllers/instrumentationdevice/common.go b/instrumentor/controllers/instrumentationdevice/common.go index f0ce20fa8..a2ae7a304 100644 --- a/instrumentor/controllers/instrumentationdevice/common.go +++ b/instrumentor/controllers/instrumentationdevice/common.go @@ -212,11 +212,11 @@ func reconcileSingleWorkload(ctx context.Context, kubeClient client.Client, inst } runtimeVersionSupport, err := versionsupport.IsRuntimeVersionSupported(ctx, instrumentedApplication.Spec.RuntimeDetails) if !runtimeVersionSupport { - err := removeInstrumentationDeviceFromWorkload(ctx, kubeClient, instrumentedApplication.Namespace, workloadKind, workloadName, ApplyInstrumentationDeviceReasonRuntimeVersionNotSupported) - if err == nil { + errRemove := removeInstrumentationDeviceFromWorkload(ctx, kubeClient, instrumentedApplication.Namespace, workloadKind, workloadName, ApplyInstrumentationDeviceReasonRuntimeVersionNotSupported) + if errRemove == nil { conditions.UpdateStatusConditions(ctx, kubeClient, instrumentedApplication, &instrumentedApplication.Status.Conditions, metav1.ConditionFalse, appliedInstrumentationDeviceType, string(ApplyInstrumentationDeviceReasonRuntimeVersionNotSupported), err.Error()) } else { - conditions.UpdateStatusConditions(ctx, kubeClient, instrumentedApplication, &instrumentedApplication.Status.Conditions, metav1.ConditionFalse, appliedInstrumentationDeviceType, string(ApplyInstrumentationDeviceReasonErrRemoving), err.Error()) + conditions.UpdateStatusConditions(ctx, kubeClient, instrumentedApplication, &instrumentedApplication.Status.Conditions, metav1.ConditionFalse, appliedInstrumentationDeviceType, string(ApplyInstrumentationDeviceReasonErrRemoving), errRemove.Error()) } return err } diff --git a/instrumentor/controllers/utils/versionsupport/java_support.go b/instrumentor/controllers/utils/versionsupport/java_support.go index 2f575011e..f50d5821d 100644 --- a/instrumentor/controllers/utils/versionsupport/java_support.go +++ b/instrumentor/controllers/utils/versionsupport/java_support.go @@ -7,8 +7,7 @@ type JavaVersionChecker struct{} var JavaMinVersion, _ = version.NewVersion("17.0.11+8") func (j JavaVersionChecker) IsVersionSupported(version *version.Version) bool { - return version.Metadata() >= JavaMinVersion.Metadata() && - version.GreaterThanOrEqual(JavaMinVersion) + return true } func (j JavaVersionChecker) GetSupportedVersion() string { diff --git a/instrumentor/controllers/utils/versionsupport/language_version_support.go b/instrumentor/controllers/utils/versionsupport/language_version_support.go index d10a2b32d..8cbec4703 100644 --- a/instrumentor/controllers/utils/versionsupport/language_version_support.go +++ b/instrumentor/controllers/utils/versionsupport/language_version_support.go @@ -30,16 +30,21 @@ func IsRuntimeVersionSupported(ctx context.Context, details []v1alpha1.RuntimeDe runtimeVersion, err := version.NewVersion(runtimeDetailsByContainer.RuntimeVersion) if err != nil { - logger.Info("Version format error: %s is not a valid version for language %s", - runtimeDetailsByContainer.RuntimeVersion, runtimeDetailsByContainer.Language) + logger.Info("Version format error: Invalid version for language", + "runtimeVersion", runtimeDetailsByContainer.RuntimeVersion, + "language", runtimeDetailsByContainer.Language, + ) return false, fmt.Errorf("Version format error: %s is not a valid version for language %s", runtimeDetailsByContainer.RuntimeVersion, runtimeDetailsByContainer.Language) } if !runtimeVersionSupporter.IsVersionSupported(runtimeVersion) { runtimeVersionOtelSDKSupport := runtimeVersionSupporter.GetSupportedVersion() - logger.Info("%s runtime version not supported by OpenTelemetry SDK. Found: %s, supports: %s", - runtimeDetailsByContainer.Language, runtimeDetailsByContainer.RuntimeVersion, runtimeVersionOtelSDKSupport) + logger.Info("Runtime version not supported by OpenTelemetry SDK", + "language", runtimeDetailsByContainer.Language, + "runtimeVersion", runtimeDetailsByContainer.RuntimeVersion, + "supportedVersions", runtimeVersionOtelSDKSupport, + ) return false, fmt.Errorf("%s runtime version not supported by OpenTelemetry SDK. Found: %s, supports: %s", runtimeDetailsByContainer.Language, runtimeDetailsByContainer.RuntimeVersion, runtimeVersionOtelSDKSupport) } diff --git a/instrumentor/controllers/utils/versionsupport/language_version_support_test.go b/instrumentor/controllers/utils/versionsupport/language_version_support_test.go index 40fd10a39..90c441e1b 100644 --- a/instrumentor/controllers/utils/versionsupport/language_version_support_test.go +++ b/instrumentor/controllers/utils/versionsupport/language_version_support_test.go @@ -14,8 +14,8 @@ func TestIsRuntimeVersionSupported_NotSupported(t *testing.T) { version string errorMsg string }{ - {"java version not supported", common.JavaProgrammingLanguage, "17.0.10+9", "java runtime version not supported by OpenTelemetry SDK. Found: 17.0.10+9, supports: 17.0.11+8"}, - {"jdk version not supported", common.JavaProgrammingLanguage, "17.0.11+7", "java runtime version not supported by OpenTelemetry SDK. Found: 17.0.11+7, supports: 17.0.11+8"}, + //{"java version not supported", common.JavaProgrammingLanguage, "17.0.10+9", "java runtime version not supported by OpenTelemetry SDK. Found: 17.0.10+9, supports: 17.0.11+8"}, + //{"jdk version not supported", common.JavaProgrammingLanguage, "17.0.11+7", "java runtime version not supported by OpenTelemetry SDK. Found: 17.0.11+7, supports: 17.0.11+8"}, {"go version not supported", common.GoProgrammingLanguage, "1.14", "go runtime version not supported by OpenTelemetry SDK. Found: 1.14, supports: 1.17.0"}, {"javascript version not supported", common.JavascriptProgrammingLanguage, "13.9.9", "javascript runtime version not supported by OpenTelemetry SDK. Found: 13.9.9, supports: 14.0.0"}, {"python version not supported", common.PythonProgrammingLanguage, "3.7", "python runtime version not supported by OpenTelemetry SDK. Found: 3.7, supports: 3.8.0"}, @@ -45,7 +45,7 @@ func TestIsRuntimeVersionSupported_Support(t *testing.T) { language common.ProgrammingLanguage version string }{ - {"java version not supported", common.JavaProgrammingLanguage, "17.0.11+9"}, + //{"java version not supported", common.JavaProgrammingLanguage, "17.0.11+9"}, {"go version not supported", common.GoProgrammingLanguage, "1.18"}, {"dotnet version not supported", common.DotNetProgrammingLanguage, "0.0.0"}, {"javascript version not supported", common.JavascriptProgrammingLanguage, "14.0.1"}, @@ -76,7 +76,7 @@ func TestIsRuntimeVersionSupported_MultiRuntimeContainer_NotSupport(t *testing.T language common.ProgrammingLanguage version string }{ - {"java version not supported", common.JavaProgrammingLanguage, "17.0.11+9"}, + //{"java version not supported", common.JavaProgrammingLanguage, "17.0.11+9"}, {"go version not supported", common.GoProgrammingLanguage, "1.18"}, {"dotnet version not supported", common.DotNetProgrammingLanguage, "0.0.0"}, {"javascript version not supported", common.JavascriptProgrammingLanguage, "14.0.1"}, @@ -110,7 +110,7 @@ func TestIsRuntimeVersionSupported_MultiRuntimeContainer_Support(t *testing.T) { language common.ProgrammingLanguage version string }{ - {"java version not supported", common.JavaProgrammingLanguage, "17.0.11+9"}, + //{"java version not supported", common.JavaProgrammingLanguage, "17.0.11+9"}, {"go version not supported", common.GoProgrammingLanguage, "1.18"}, {"dotnet version not supported", common.DotNetProgrammingLanguage, "0.0.0"}, {"javascript version not supported", common.JavascriptProgrammingLanguage, "14.0.1"},