Skip to content

Commit

Permalink
Language detection in Odiglet (#167)
Browse files Browse the repository at this point in the history
This PR contains the following changes to Odigos:

- **Refactor language detection**: instead of creating and deleting
pods, Odigos now detects languages via Odiglet.
- **Labeling support**: Odigos detects and instruments applications
according to labeled namespaces, deployments, etc
- **Reduced required permissions**: Odigos now does not require
permission to delete objects like Pods, Deployments, etc.
  • Loading branch information
edeNFed authored May 15, 2023
1 parent 2186d4d commit 0a4dd14
Show file tree
Hide file tree
Showing 87 changed files with 7,942 additions and 2,045 deletions.
9 changes: 1 addition & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,18 +30,11 @@ jobs:
push: false
tags: instrumentor:pr-${{ github.event.number }}
build-args: SERVICE_NAME=instrumentor
- name: Build Detector Image
uses: docker/build-push-action@v4
with:
file: langDetector/Dockerfile
push: false
tags: lang-detector:pr-${{ github.event.number }}
build-args: SERVICE_NAME=langDetector
- name: Build Odiglet Image
uses: docker/build-push-action@v4
with:
file: odiglet/Dockerfile
context: odiglet/
context: .
push: false
tags: odiglet:pr-${{ github.event.number }}
- name: Build UI Image
Expand Down
17 changes: 0 additions & 17 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,13 @@ jobs:
tags: ghcr.io/keyval-dev/odigos/instrumentor:${{ steps.vars.outputs.tag }}
build-args: SERVICE_NAME=instrumentor
platforms: linux/amd64,linux/arm64
- name: Build Detector Image
uses: docker/build-push-action@v4
with:
file: langDetector/Dockerfile
push: true
tags: ghcr.io/keyval-dev/odigos/lang-detector:${{ steps.vars.outputs.tag }}
build-args: SERVICE_NAME=langDetector
platforms: linux/amd64,linux/arm64
- name: Build Odiglet Image
uses: docker/build-push-action@v4
with:
file: odiglet/Dockerfile
context: odiglet/
push: true
tags: ghcr.io/keyval-dev/odigos/odiglet:${{ steps.vars.outputs.tag }}
platforms: linux/amd64,linux/arm64
- name: Build Init Image
uses: docker/build-push-action@v4
with:
file: init/Dockerfile
context: init/
push: true
tags: ghcr.io/keyval-dev/odigos/init:${{ steps.vars.outputs.tag }}
platforms: linux/amd64,linux/arm64
- name: Build UI Image
uses: docker/build-push-action@v4
with:
Expand Down
8 changes: 1 addition & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,22 @@
build-images:
docker build -t ghcr.io/keyval-dev/odigos/autoscaler:$(TAG) . --build-arg SERVICE_NAME=autoscaler
docker build -t ghcr.io/keyval-dev/odigos/scheduler:$(TAG) . --build-arg SERVICE_NAME=scheduler
docker build -t ghcr.io/keyval-dev/odigos/lang-detector:$(TAG) -f langDetector/Dockerfile . --build-arg SERVICE_NAME=langDetector
docker build -t ghcr.io/keyval-dev/odigos/ui:$(TAG) ui/ -f ui/Dockerfile
docker build -t ghcr.io/keyval-dev/odigos/odiglet:$(TAG) odiglet/ -f odiglet/Dockerfile
docker build -t ghcr.io/keyval-dev/odigos/init:$(TAG) init/ -f init/Dockerfile
docker build -t ghcr.io/keyval-dev/odigos/odiglet:$(TAG) . -f odiglet/Dockerfile
docker build -t ghcr.io/keyval-dev/odigos/instrumentor:$(TAG) . --build-arg SERVICE_NAME=instrumentor

.PHONY: push-images
push-images:
docker push ghcr.io/keyval-dev/odigos/autoscaler:$(TAG)
docker push ghcr.io/keyval-dev/odigos/scheduler:$(TAG)
docker push ghcr.io/keyval-dev/odigos/lang-detector:$(TAG)
docker push ghcr.io/keyval-dev/odigos/ui:$(TAG)
docker push ghcr.io/keyval-dev/odigos/instrumentor:$(TAG)
docker push ghcr.io/keyval-dev/odigos/init:$(TAG)
docker push ghcr.io/keyval-dev/odigos/odiglet:$(TAG)

.PHONY: load-to-kind
load-to-kind:
kind load docker-image ghcr.io/keyval-dev/odigos/autoscaler:$(TAG)
kind load docker-image ghcr.io/keyval-dev/odigos/scheduler:$(TAG)
kind load docker-image ghcr.io/keyval-dev/odigos/lang-detector:$(TAG)
kind load docker-image ghcr.io/keyval-dev/odigos/ui:$(TAG)
kind load docker-image ghcr.io/keyval-dev/odigos/odiglet:$(TAG)
kind load docker-image ghcr.io/keyval-dev/odigos/init:$(TAG)
kind load docker-image ghcr.io/keyval-dev/odigos/instrumentor:$(TAG)
Binary file modified api/bin/controller-gen
Binary file not shown.
Binary file removed api/bin/kustomize
Binary file not shown.
21 changes: 0 additions & 21 deletions api/config/crd/bases/odigos.io_instrumentedapplications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ spec:
description: InstrumentedApplicationSpec defines the desired state of
InstrumentedApplication
properties:
enabled:
type: boolean
languages:
items:
properties:
Expand All @@ -59,29 +57,10 @@ spec:
- language
type: object
type: array
waitingForDataCollection:
type: boolean
required:
- waitingForDataCollection
type: object
status:
description: InstrumentedApplicationStatus defines the observed state
of InstrumentedApplication
properties:
instrumented:
type: boolean
langDetection:
properties:
phase:
enum:
- Pending
- Running
- Completed
- Error
type: string
type: object
required:
- instrumented
type: object
type: object
served: true
Expand Down
20 changes: 1 addition & 19 deletions api/odigos/v1alpha1/instrumentedapplication_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,31 +23,13 @@ import (

// InstrumentedApplicationSpec defines the desired state of InstrumentedApplication
type InstrumentedApplicationSpec struct {
Languages []common.LanguageByContainer `json:"languages,omitempty"`
Enabled *bool `json:"enabled,omitempty"`
WaitingForDataCollection bool `json:"waitingForDataCollection"`
Languages []common.LanguageByContainer `json:"languages,omitempty"`
}

// InstrumentedApplicationStatus defines the observed state of InstrumentedApplication
type InstrumentedApplicationStatus struct {
LangDetection LangDetectionStatus `json:"langDetection,omitempty"`
Instrumented bool `json:"instrumented"`
}

type LangDetectionStatus struct {
Phase LangDetectionPhase `json:"phase,omitempty"`
}

//+kubebuilder:validation:Enum=Pending;Running;Completed;Error
type LangDetectionPhase string

const (
PendingLangDetectionPhase LangDetectionPhase = "Pending"
RunningLangDetectionPhase LangDetectionPhase = "Running"
CompletedLangDetectionPhase LangDetectionPhase = "Completed"
ErrorLangDetectionPhase LangDetectionPhase = "Error"
)

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

Expand Down
21 changes: 0 additions & 21 deletions api/odigos/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion autoscaler/controllers/datacollection/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package datacollection
import (
"context"
odigosv1 "github.com/keyval-dev/odigos/api/odigos/v1alpha1"
appsv1 "k8s.io/api/apps/v1"
"k8s.io/apimachinery/pkg/runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
"sigs.k8s.io/controller-runtime/pkg/log"
Expand Down Expand Up @@ -62,11 +63,16 @@ func syncDataCollection(instApps *odigosv1.InstrumentedApplicationList, dests *o
return err
}

dataCollection.Status.Ready = ds.Status.DesiredNumberScheduled == ds.Status.NumberReady
dataCollection.Status.Ready = calcDataCollectionReadyStatus(ds)
if err := c.Status().Update(ctx, dataCollection); err != nil {
logger.Error(err, "failed to update data collection status")
return err
}

return nil
}

// Data collection is ready if at least 50% of the pods are ready
func calcDataCollectionReadyStatus(ds *appsv1.DaemonSet) bool {
return float64(ds.Status.NumberReady) >= float64(ds.Status.DesiredNumberScheduled)/float64(2)
}
4 changes: 4 additions & 0 deletions common/consts/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const (
DefaultOdigosConfigurationName = "odigos-config"
OTLPPort = 4317
OTLPHttpPort = 4318
OdigosInstrumentationLabel = "odigos-instrumentation"
InstrumentationEnabled = "enabled"
InstrumentationDisabled = "disabled"
GolangInstrumentationImage = "keyval/otel-go-agent:v0.6.5"
)

var (
Expand Down
19 changes: 19 additions & 0 deletions common/utils/names.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package utils

import (
"errors"
"strings"
)

func GetRuntimeObjectName(name string, kind string) string {
return strings.ToLower(kind + "-" + name)
}

func GetTargetFromRuntimeName(name string) (string, string, error) {
parts := strings.Split(name, "-")
if len(parts) < 2 {
return "", "", errors.New("invalid runtime name")
}

return strings.Join(parts[1:], "-"), parts[0], nil
}
9 changes: 0 additions & 9 deletions init/Dockerfile

This file was deleted.

3 changes: 0 additions & 3 deletions init/go.mod

This file was deleted.

110 changes: 0 additions & 110 deletions init/main.go

This file was deleted.

Loading

0 comments on commit 0a4dd14

Please sign in to comment.