Skip to content

Commit

Permalink
fix: handle unknown and ignored languages in supported check (#1516)
Browse files Browse the repository at this point in the history
  • Loading branch information
blumamir authored Sep 18, 2024
1 parent 8803649 commit 83f7548
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
15 changes: 15 additions & 0 deletions instrumentor/controllers/utils/versionsupport/ignored_support.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package versionsupport

import "github.com/hashicorp/go-version"

type IgnoredVersionCheck struct{}

func (g IgnoredVersionCheck) IsVersionSupported(version *version.Version) bool {
// ignored containers are anyhow not used for device injection.
// we will return true here so not to fail all containers due to this check.
return true
}

func (g IgnoredVersionCheck) GetSupportedVersion() string {
return ""
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package versionsupport
import (
"context"
"fmt"

"github.com/hashicorp/go-version"
"github.com/odigos-io/odigos/api/odigos/v1alpha1"
"github.com/odigos-io/odigos/common"
Expand Down Expand Up @@ -69,6 +70,10 @@ func getRuntimeVersionCheck(language common.ProgrammingLanguage) RuntimeVersionC
return &NginxVersionCheck{}
case common.MySQLProgrammingLanguage:
return &MySQLVersionCheck{}
case common.UnknownProgrammingLanguage:
return &UnknownVersionCheck{}
case common.IgnoredProgrammingLanguage:
return &IgnoredVersionCheck{}
default:
return nil
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
package versionsupport

import (
"testing"

"github.com/odigos-io/odigos/api/odigos/v1alpha1"
"github.com/odigos-io/odigos/common"
"github.com/stretchr/testify/assert"
"testing"
)

func TestIsRuntimeVersionSupported_NotSupported(t *testing.T) {
Expand All @@ -21,7 +22,7 @@ func TestIsRuntimeVersionSupported_NotSupported(t *testing.T) {
{"python version not supported", common.PythonProgrammingLanguage, "3.7", "python runtime version not supported by OpenTelemetry SDK. Found: 3.7, supports: 3.8.0"},
{"nginx version not supported", common.NginxProgrammingLanguage, "1.25.4", "nginx runtime version not supported by OpenTelemetry SDK. Found: 1.25.4, supports: 1.25.5, 1.26.0"},
{"nginx version not supported", common.NginxProgrammingLanguage, "1.26.1", "nginx runtime version not supported by OpenTelemetry SDK. Found: 1.26.1, supports: 1.25.5, 1.26.0"},
{"unknown language", common.UnknownProgrammingLanguage, "0.0.0", "Unsupported language: unknown"},
// {"unknown language", common.UnknownProgrammingLanguage, "0.0.0", "Unsupported language: unknown"},
}

for _, tc := range testCases {
Expand Down
15 changes: 15 additions & 0 deletions instrumentor/controllers/utils/versionsupport/unknown_support.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package versionsupport

import "github.com/hashicorp/go-version"

type UnknownVersionCheck struct{}

func (g UnknownVersionCheck) IsVersionSupported(version *version.Version) bool {
// if we return false here, it will fail all device injection into all containers in the pod.
// we return true here, which anyhow will not inject any device into the container.
return true
}

func (g UnknownVersionCheck) GetSupportedVersion() string {
return ""
}

0 comments on commit 83f7548

Please sign in to comment.