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

feat: removing resourcenameprocessor for enterprise #1578

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
4 changes: 3 additions & 1 deletion autoscaler/controllers/collectorsgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"github.com/odigos-io/odigos/autoscaler/controllers/datacollection"
"github.com/odigos-io/odigos/autoscaler/controllers/gateway"

"github.com/odigos-io/odigos/common"
"sigs.k8s.io/controller-runtime/pkg/log"

"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -36,6 +37,7 @@ type CollectorsGroupReconciler struct {
Scheme *runtime.Scheme
ImagePullSecrets []string
OdigosVersion string
OdigosTier common.OdigosTier
}

//+kubebuilder:rbac:groups=odigos.io,namespace=odigos-system,resources=collectorsgroups,verbs=get;list;watch;create;update;patch;delete
Expand Down Expand Up @@ -65,7 +67,7 @@ func (r *CollectorsGroupReconciler) Reconcile(ctx context.Context, req ctrl.Requ
return ctrl.Result{}, err
}

err = datacollection.Sync(ctx, r.Client, r.Scheme, r.ImagePullSecrets, r.OdigosVersion)
err = datacollection.Sync(ctx, r.Client, r.Scheme, r.ImagePullSecrets, r.OdigosVersion, r.OdigosTier)
if err != nil {
return ctrl.Result{}, err
}
Expand Down
54 changes: 34 additions & 20 deletions autoscaler/controllers/datacollection/configmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,13 @@ import (
"slices"
"strings"

"github.com/odigos-io/odigos/autoscaler/controllers/datacollection/custom"
"github.com/odigos-io/odigos/common"
"github.com/odigos-io/odigos/common/consts"

"github.com/ghodss/yaml"
odigosv1 "github.com/odigos-io/odigos/api/odigos/v1alpha1"
commonconf "github.com/odigos-io/odigos/autoscaler/controllers/common"
"github.com/odigos-io/odigos/autoscaler/controllers/datacollection/custom"
"github.com/odigos-io/odigos/common"
"github.com/odigos-io/odigos/common/config"
"github.com/odigos-io/odigos/common/consts"
constsK8s "github.com/odigos-io/odigos/k8sutils/pkg/consts"
"github.com/odigos-io/odigos/k8sutils/pkg/env"
v1 "k8s.io/api/core/v1"
Expand All @@ -30,7 +29,7 @@ import (

func SyncConfigMap(apps *odigosv1.InstrumentedApplicationList, dests *odigosv1.DestinationList, allProcessors *odigosv1.ProcessorList,
datacollection *odigosv1.CollectorsGroup, ctx context.Context,
c client.Client, scheme *runtime.Scheme) (string, error) {
c client.Client, scheme *runtime.Scheme, tier common.OdigosTier) (string, error) {
logger := log.FromContext(ctx)

processors := commonconf.FilterAndSortProcessorsByOrderHint(allProcessors, odigosv1.CollectorsGroupRoleNodeCollector)
Expand All @@ -39,7 +38,7 @@ func SyncConfigMap(apps *odigosv1.InstrumentedApplicationList, dests *odigosv1.D
SamplingExists := commonconf.FindFirstProcessorByType(allProcessors, "odigossampling")
setTracesLoadBalancer := SamplingExists != nil

desired, err := getDesiredConfigMap(apps, dests, processors, datacollection, scheme, setTracesLoadBalancer)
desired, err := getDesiredConfigMap(apps, dests, processors, datacollection, scheme, setTracesLoadBalancer, tier)
if err != nil {
logger.Error(err, "failed to get desired config map")
return "", err
Expand Down Expand Up @@ -98,8 +97,8 @@ func createConfigMap(desired *v1.ConfigMap, ctx context.Context, c client.Client
}

func getDesiredConfigMap(apps *odigosv1.InstrumentedApplicationList, dests *odigosv1.DestinationList, processors []*odigosv1.Processor,
datacollection *odigosv1.CollectorsGroup, scheme *runtime.Scheme, setTracesLoadBalancer bool) (*v1.ConfigMap, error) {
cmData, err := calculateConfigMapData(apps, dests, processors, setTracesLoadBalancer)
datacollection *odigosv1.CollectorsGroup, scheme *runtime.Scheme, setTracesLoadBalancer bool, tier common.OdigosTier) (*v1.ConfigMap, error) {
cmData, err := calculateConfigMapData(apps, dests, processors, setTracesLoadBalancer, tier)
if err != nil {
return nil, err
}
Expand All @@ -126,7 +125,7 @@ func getDesiredConfigMap(apps *odigosv1.InstrumentedApplicationList, dests *odig
}

func calculateConfigMapData(apps *odigosv1.InstrumentedApplicationList, dests *odigosv1.DestinationList, processors []*odigosv1.Processor,
setTracesLoadBalancer bool) (string, error) {
setTracesLoadBalancer bool, tier common.OdigosTier) (string, error) {

empty := struct{}{}

Expand All @@ -136,8 +135,12 @@ func calculateConfigMapData(apps *odigosv1.InstrumentedApplicationList, dests *o
log.Log.V(0).Info(err.Error(), "processor", name)
}
}

if tier != common.OnPremOdigosTier {
processorsCfg["odigosresourcename"] = empty
}

processorsCfg["batch"] = empty
processorsCfg["odigosresourcename"] = empty
processorsCfg["resource"] = config.GenericMap{
"attributes": []config.GenericMap{{
"key": "k8s.node.name",
Expand Down Expand Up @@ -207,7 +210,7 @@ func calculateConfigMapData(apps *odigosv1.InstrumentedApplicationList, dests *o
"config": config.GenericMap{
"scrape_configs": []config.GenericMap{
{
"job_name": "otelcol",
"job_name": "otelcol",
"scrape_interval": "10s",
"static_configs": []config.GenericMap{
{
Expand All @@ -217,8 +220,8 @@ func calculateConfigMapData(apps *odigosv1.InstrumentedApplicationList, dests *o
"metric_relabel_configs": []config.GenericMap{
{
"source_labels": []string{"__name__"},
"regex": "(.*odigos.*|^otelcol_processor_accepted.*)",
"action": "keep",
"regex": "(.*odigos.*|^otelcol_processor_accepted.*)",
"action": "keep",
},
},
},
Expand All @@ -234,11 +237,11 @@ func calculateConfigMapData(apps *odigosv1.InstrumentedApplicationList, dests *o
},
},
Service: config.Service{
Pipelines: map[string]config.Pipeline{
Pipelines: map[string]config.Pipeline{
"metrics/otelcol": {
Receivers: []string{"prometheus/self-metrics"},
Receivers: []string{"prometheus/self-metrics"},
Processors: []string{"resource/pod-name"},
Exporters: []string{"otlp/odigos-own-telemetry-ui"},
Exporters: []string{"otlp/odigos-own-telemetry-ui"},
},
},
Extensions: []string{"health_check"},
Expand All @@ -249,7 +252,7 @@ func calculateConfigMapData(apps *odigosv1.InstrumentedApplicationList, dests *o
Resource: map[string]*string{
// The collector add "otelcol" as a service name, so we need to remove it
// to avoid duplication, since we are interested in the instrumented services.
string(semconv.ServiceNameKey): nil,
string(semconv.ServiceNameKey): nil,
// The collector adds its own version as a service version, which is not needed currently.
string(semconv.ServiceVersionKey): nil,
},
Expand All @@ -274,6 +277,8 @@ func calculateConfigMapData(apps *odigosv1.InstrumentedApplicationList, dests *o
}
}

commonProcessors := getCommonProcessorsByTier(tier)

if collectLogs {
includes := make([]string, 0)
for _, element := range apps.Items {
Expand Down Expand Up @@ -313,15 +318,15 @@ func calculateConfigMapData(apps *odigosv1.InstrumentedApplicationList, dests *o

cfg.Service.Pipelines["logs"] = config.Pipeline{
Receivers: []string{"filelog"},
Processors: append([]string{"batch", "odigosresourcename", "resource", "resourcedetection", "odigostrafficmetrics"}, logsProcessors...),
Processors: append(commonProcessors, logsProcessors...),
Exporters: []string{"otlp/gateway"},
}
}

if collectTraces {
cfg.Service.Pipelines["traces"] = config.Pipeline{
Receivers: []string{"otlp"},
Processors: append([]string{"batch", "odigosresourcename", "resource", "resourcedetection", "odigostrafficmetrics"}, tracesProcessors...),
Processors: append(commonProcessors, tracesProcessors...),
Exporters: tracesPipelineExporter,
}
}
Expand All @@ -336,7 +341,7 @@ func calculateConfigMapData(apps *odigosv1.InstrumentedApplicationList, dests *o

cfg.Service.Pipelines["metrics"] = config.Pipeline{
Receivers: []string{"otlp", "kubeletstats"},
Processors: append([]string{"batch", "odigosresourcename", "resource", "resourcedetection", "odigostrafficmetrics"}, metricsProcessors...),
Processors: append(commonProcessors, metricsProcessors...),
Exporters: []string{"otlp/gateway"},
}
}
Expand Down Expand Up @@ -396,3 +401,12 @@ func getSignalsFromOtelcolConfig(otelcolConfigContent string) ([]common.Observab

return signals, nil
}

func getCommonProcessorsByTier(tier common.OdigosTier) []string {
processors := []string{"batch"}
if tier != common.OnPremOdigosTier {
processors = append(processors, "odigosresourcename")
}
processors = append(processors, "resource", "resourcedetection", "odigostrafficmetrics")
return processors
}
2 changes: 1 addition & 1 deletion autoscaler/controllers/datacollection/configmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ func TestCalculateConfigMapData(t *testing.T) {
},
},
},
false)
false, common.CommunityOdigosTier)

assert.Equal(t, err, nil)
assert.Equal(t, want, got)
Expand Down
9 changes: 5 additions & 4 deletions autoscaler/controllers/datacollection/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"time"

odigosv1 "github.com/odigos-io/odigos/api/odigos/v1alpha1"
"github.com/odigos-io/odigos/common"
"github.com/odigos-io/odigos/k8sutils/pkg/consts"
"github.com/odigos-io/odigos/k8sutils/pkg/env"
"k8s.io/apimachinery/pkg/runtime"
Expand All @@ -18,7 +19,7 @@ const (
syncDaemonsetRetry = 3
)

func Sync(ctx context.Context, c client.Client, scheme *runtime.Scheme, imagePullSecrets []string, odigosVersion string) error {
func Sync(ctx context.Context, c client.Client, scheme *runtime.Scheme, imagePullSecrets []string, odigosVersion string, tier common.OdigosTier) error {
logger := log.FromContext(ctx)

var instApps odigosv1.InstrumentedApplicationList
Expand Down Expand Up @@ -51,16 +52,16 @@ func Sync(ctx context.Context, c client.Client, scheme *runtime.Scheme, imagePul
return err
}

return syncDataCollection(&instApps, &dests, &processors, &dataCollectionCollectorGroup, ctx, c, scheme, imagePullSecrets, odigosVersion)
return syncDataCollection(&instApps, &dests, &processors, &dataCollectionCollectorGroup, ctx, c, scheme, imagePullSecrets, odigosVersion, tier)
}

func syncDataCollection(instApps *odigosv1.InstrumentedApplicationList, dests *odigosv1.DestinationList, processors *odigosv1.ProcessorList,
dataCollection *odigosv1.CollectorsGroup, ctx context.Context, c client.Client,
scheme *runtime.Scheme, imagePullSecrets []string, odigosVersion string) error {
scheme *runtime.Scheme, imagePullSecrets []string, odigosVersion string, tier common.OdigosTier) error {
logger := log.FromContext(ctx)
logger.V(0).Info("Syncing data collection")

_, err := SyncConfigMap(instApps, dests, processors, dataCollection, ctx, c, scheme)
_, err := SyncConfigMap(instApps, dests, processors, dataCollection, ctx, c, scheme, tier)
if err != nil {
logger.Error(err, "Failed to sync config map")
return err
Expand Down
4 changes: 3 additions & 1 deletion autoscaler/controllers/instrumentedapplication_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (

odigosv1 "github.com/odigos-io/odigos/api/odigos/v1alpha1"
"github.com/odigos-io/odigos/autoscaler/controllers/datacollection"
"github.com/odigos-io/odigos/common"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -33,6 +34,7 @@ type InstrumentedApplicationReconciler struct {
Scheme *runtime.Scheme
ImagePullSecrets []string
OdigosVersion string
OdigosTier common.OdigosTier
}

//+kubebuilder:rbac:groups=odigos.io,resources=instrumentedapplications,verbs=get;list;watch;create;update;patch;delete
Expand All @@ -50,7 +52,7 @@ type InstrumentedApplicationReconciler struct {
func (r *InstrumentedApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
logger := log.FromContext(ctx)
logger.V(0).Info("Reconciling InstrumentedApps")
err := datacollection.Sync(ctx, r.Client, r.Scheme, r.ImagePullSecrets, r.OdigosVersion)
err := datacollection.Sync(ctx, r.Client, r.Scheme, r.ImagePullSecrets, r.OdigosVersion, r.OdigosTier)
if err != nil {
return ctrl.Result{}, err
}
Expand Down
4 changes: 3 additions & 1 deletion autoscaler/controllers/processor_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
v1 "github.com/odigos-io/odigos/api/odigos/v1alpha1"
"github.com/odigos-io/odigos/autoscaler/controllers/datacollection"
"github.com/odigos-io/odigos/autoscaler/controllers/gateway"
"github.com/odigos-io/odigos/common"
"k8s.io/apimachinery/pkg/runtime"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/client"
Expand All @@ -17,6 +18,7 @@ type ProcessorReconciler struct {
Scheme *runtime.Scheme
ImagePullSecrets []string
OdigosVersion string
OdigosTier common.OdigosTier
}

func (r *ProcessorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
Expand All @@ -29,7 +31,7 @@ func (r *ProcessorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (
return ctrl.Result{}, err
}

err = datacollection.Sync(ctx, r.Client, r.Scheme, r.ImagePullSecrets, r.OdigosVersion)
err = datacollection.Sync(ctx, r.Client, r.Scheme, r.ImagePullSecrets, r.OdigosVersion, r.OdigosTier)
if err != nil {
return ctrl.Result{}, err
}
Expand Down
16 changes: 8 additions & 8 deletions autoscaler/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ require (
github.com/cenkalti/backoff/v4 v4.3.0 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
github.com/emicklei/go-restful/v3 v3.12.0 // indirect
github.com/evanphx/json-patch/v5 v5.9.0 // indirect
github.com/fatih/color v1.16.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
github.com/go-logr/stdr v1.2.2 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.2 // indirect
github.com/go-openapi/swag v0.22.4 // indirect
github.com/go-openapi/jsonpointer v0.21.0 // indirect
github.com/go-openapi/jsonreference v0.21.0 // indirect
github.com/go-openapi/swag v0.23.0 // indirect
github.com/goccy/go-yaml v1.11.3 // indirect
github.com/gogo/protobuf v1.3.2 // indirect
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
Expand All @@ -44,7 +44,7 @@ require (
github.com/google/uuid v1.6.0 // indirect
github.com/grpc-ecosystem/grpc-gateway/v2 v2.20.0 // indirect
github.com/hashicorp/go-version v1.7.0 // indirect
github.com/imdario/mergo v0.3.12 // indirect
github.com/imdario/mergo v0.3.16 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/mailru/easyjson v0.7.7 // indirect
Expand All @@ -70,10 +70,10 @@ require (
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
golang.org/x/net v0.26.0 // indirect
golang.org/x/oauth2 v0.21.0 // indirect
golang.org/x/sys v0.21.0 // indirect
golang.org/x/sys v0.22.0 // indirect
golang.org/x/term v0.21.0 // indirect
golang.org/x/text v0.16.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/xerrors v0.0.0-20231012003039-104605ab7028 // indirect
gomodules.xyz/jsonpatch/v2 v2.4.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240528184218-531527333157 // indirect
Expand All @@ -85,7 +85,7 @@ require (
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/apiextensions-apiserver v0.31.0 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
k8s.io/kube-openapi v0.0.0-20240430033511-f0e62f92d13f // indirect
k8s.io/utils v0.0.0-20240711033017-18e509b52bc8 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
Expand Down
Loading
Loading