Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "unknown" programming language #1178

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@ build-odiglet:
build-autoscaler:
docker build -t keyval/odigos-autoscaler:$(TAG) . --build-arg SERVICE_NAME=autoscaler

.PHONY: build-instrumentor
build-instrumentor:
docker build -t keyval/odigos-instrumentor:$(TAG) . --build-arg SERVICE_NAME=instrumentor

.PHONY: build-scheduler
build-scheduler:
docker build -t keyval/odigos-scheduler:$(TAG) . --build-arg SERVICE_NAME=scheduler

.PHONY: build-collector
build-collector:
docker build -t keyval/odigos-collector:$(TAG) collector -f collector/Dockerfile

.PHONY: build-images
build-images:
make build-autoscaler TAG=$(TAG)
docker build -t keyval/odigos-scheduler:$(TAG) . --build-arg SERVICE_NAME=scheduler
make build-scheduler TAG=$(TAG)
make build-odiglet TAG=$(TAG)
docker build -t keyval/odigos-instrumentor:$(TAG) . --build-arg SERVICE_NAME=instrumentor
make build-instrumentor TAG=$(TAG)
make build-collector TAG=$(TAG)

.PHONY: push-images
Expand All @@ -38,6 +46,10 @@ load-to-kind-autoscaler:
load-to-kind-collector:
kind load docker-image keyval/odigos-collector:$(TAG)

.PHONY: load-to-kind-instrumentor
load-to-kind-instrumentor:
kind load docker-image keyval/odigos-instrumentor:$(TAG)

.PHONY: load-to-kind
load-to-kind:
make load-to-kind-autoscaler TAG=$(TAG)
Expand All @@ -54,6 +66,10 @@ restart-odiglet:
restart-autoscaler:
kubectl rollout restart deployment odigos-autoscaler -n odigos-system

.PHONY: restart-instrumentor
restart-instrumentor:
kubectl rollout restart deployment odigos-instrumentor -n odigos-system

.PHONY: restart-collector
restart-collector:
kubectl rollout restart deployment odigos-gateway -n odigos-system
Expand All @@ -72,6 +88,10 @@ deploy-autoscaler:
deploy-collector:
make build-collector TAG=$(TAG) && make load-to-kind-collector TAG=$(TAG) && make restart-collector

.PHONY: deploy-instrumentor
deploy-instrumentor:
make build-instrumentor TAG=$(TAG) && make load-to-kind-instrumentor TAG=$(TAG) && make restart-instrumentor

.PHONY: debug-odiglet
debug-odiglet:
docker build -t keyval/odigos-odiglet:$(TAG) . -f odiglet/debug.Dockerfile
Expand Down
1 change: 1 addition & 0 deletions api/config/crd/bases/odigos.io_instrumentationconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ spec:
- dotnet
- javascript
- mysql
- unknown
type: string
required:
- instrumentationLibraryName
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ spec:
- dotnet
- javascript
- mysql
- unknown
type: string
required:
- containerName
Expand Down
3 changes: 3 additions & 0 deletions cli/cmd/resources/crds/instrumentedapps.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,9 @@ func NewInstrumentedApp() *apiextensionsv1.CustomResourceDefinition {
{
Raw: []byte(`"mysql"`),
},
{
Raw: []byte(`"unknown"`),
},
},
},
"envVars": {
Expand Down
4 changes: 3 additions & 1 deletion common/lang_detection.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package common

// +kubebuilder:validation:Enum=java;python;go;dotnet;javascript;mysql
// +kubebuilder:validation:Enum=java;python;go;dotnet;javascript;mysql;unknown
type ProgrammingLanguage string

const (
Expand All @@ -12,4 +12,6 @@ const (
// This is an experimental feature, It is not a language
// but in order to avoid huge refactoring we are adding it here for now
MySQLProgrammingLanguage ProgrammingLanguage = "mysql"
// Used when the language detection is not successful for all the available inspectors
UnknownProgrammingLanguage ProgrammingLanguage = "unknown"
)
2 changes: 1 addition & 1 deletion instrumentor/instrumentation/instrumentation.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func ApplyInstrumentationDevicesToPodTemplate(original *v1.PodTemplateSpec, runt
var modifiedContainers []v1.Container
for _, container := range original.Spec.Containers {
containerLanguage := getLanguageOfContainer(runtimeDetails, container.Name)
if containerLanguage == nil {
if containerLanguage == nil || *containerLanguage == common.UnknownProgrammingLanguage {
modifiedContainers = append(modifiedContainers, container)
continue
}
Expand Down
6 changes: 3 additions & 3 deletions odiglet/pkg/kube/runtime_details/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"github.com/odigos-io/odigos/odiglet/pkg/log"
"github.com/odigos-io/odigos/odiglet/pkg/process"
"github.com/odigos-io/odigos/procdiscovery/pkg/inspectors"
"github.com/odigos-io/odigos/common"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -71,9 +72,8 @@ func runtimeInspection(pods []corev1.Pod) ([]odigosv1.RuntimeDetailsByContainer,
process := processes[0]

lang := inspectors.DetectLanguage(process)
if lang == nil {
if lang == common.UnknownProgrammingLanguage {
log.Logger.V(0).Info("no supported language detected for container in pod", "process", process, "pod", pod.Name, "container", container.Name, "namespace", pod.Namespace)
continue
}

// Convert map to slice for k8s format
Expand All @@ -84,7 +84,7 @@ func runtimeInspection(pods []corev1.Pod) ([]odigosv1.RuntimeDetailsByContainer,

resultsMap[container.Name] = odigosv1.RuntimeDetailsByContainer{
ContainerName: container.Name,
Language: *lang,
Language: lang,
EnvVars: envs,
}
}
Expand Down
6 changes: 3 additions & 3 deletions procdiscovery/pkg/inspectors/langdetect.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ var inspectorsList = []inspector{
var ErrLanguageNotDetected = errors.New("language not detected")

// DetectLanguage returns the detected language for the process or nil if the language could not be detected
func DetectLanguage(process process.Details) *common.ProgrammingLanguage {
func DetectLanguage(process process.Details) common.ProgrammingLanguage {
for _, i := range inspectorsList {
language, detected := i.Inspect(&process)
if detected {
return &language
return language
}
}

return nil
return common.UnknownProgrammingLanguage
}
Loading