Skip to content

Commit

Permalink
feat: Fix version log (#1494)
Browse files Browse the repository at this point in the history
  • Loading branch information
yodigos authored Sep 12, 2024
1 parent a0c8fd9 commit 99c7768
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 14 deletions.
6 changes: 3 additions & 3 deletions instrumentor/controllers/instrumentationdevice/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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"},
Expand Down

0 comments on commit 99c7768

Please sign in to comment.