diff --git a/autoscaler/controllers/collectorsgroup_controller.go b/autoscaler/controllers/collectorsgroup_controller.go index 4136f3b7f..0ef5779dc 100644 --- a/autoscaler/controllers/collectorsgroup_controller.go +++ b/autoscaler/controllers/collectorsgroup_controller.go @@ -23,7 +23,6 @@ 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" @@ -34,10 +33,10 @@ import ( // CollectorsGroupReconciler reconciles a CollectorsGroup object type CollectorsGroupReconciler struct { client.Client - Scheme *runtime.Scheme - ImagePullSecrets []string - OdigosVersion string - OdigosTier common.OdigosTier + Scheme *runtime.Scheme + ImagePullSecrets []string + OdigosVersion string + DisableNameProcessor bool } //+kubebuilder:rbac:groups=odigos.io,namespace=odigos-system,resources=collectorsgroups,verbs=get;list;watch;create;update;patch;delete @@ -67,7 +66,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, r.OdigosTier) + err = datacollection.Sync(ctx, r.Client, r.Scheme, r.ImagePullSecrets, r.OdigosVersion, r.DisableNameProcessor) if err != nil { return ctrl.Result{}, err } diff --git a/autoscaler/controllers/datacollection/configmap.go b/autoscaler/controllers/datacollection/configmap.go index 333a1c430..c5fd60505 100644 --- a/autoscaler/controllers/datacollection/configmap.go +++ b/autoscaler/controllers/datacollection/configmap.go @@ -29,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, tier common.OdigosTier) (string, error) { + c client.Client, scheme *runtime.Scheme, disableNameProcessor bool) (string, error) { logger := log.FromContext(ctx) processors := commonconf.FilterAndSortProcessorsByOrderHint(allProcessors, odigosv1.CollectorsGroupRoleNodeCollector) @@ -38,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, tier) + desired, err := getDesiredConfigMap(apps, dests, processors, datacollection, scheme, setTracesLoadBalancer, disableNameProcessor) if err != nil { logger.Error(err, "failed to get desired config map") return "", err @@ -97,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, tier common.OdigosTier) (*v1.ConfigMap, error) { - cmData, err := calculateConfigMapData(apps, dests, processors, setTracesLoadBalancer, tier) + datacollection *odigosv1.CollectorsGroup, scheme *runtime.Scheme, setTracesLoadBalancer bool, disableNameProcessor bool) (*v1.ConfigMap, error) { + cmData, err := calculateConfigMapData(apps, dests, processors, setTracesLoadBalancer, disableNameProcessor) if err != nil { return nil, err } @@ -125,7 +125,7 @@ func getDesiredConfigMap(apps *odigosv1.InstrumentedApplicationList, dests *odig } func calculateConfigMapData(apps *odigosv1.InstrumentedApplicationList, dests *odigosv1.DestinationList, processors []*odigosv1.Processor, - setTracesLoadBalancer bool, tier common.OdigosTier) (string, error) { + setTracesLoadBalancer bool, disableNameProcessor bool) (string, error) { empty := struct{}{} @@ -136,7 +136,7 @@ func calculateConfigMapData(apps *odigosv1.InstrumentedApplicationList, dests *o } } - if tier != common.OnPremOdigosTier { + if !disableNameProcessor { processorsCfg["odigosresourcename"] = empty } @@ -277,7 +277,7 @@ func calculateConfigMapData(apps *odigosv1.InstrumentedApplicationList, dests *o } } - commonProcessors := getCommonProcessorsByTier(tier) + commonProcessors := getCommonProcessors(disableNameProcessor) if collectLogs { includes := make([]string, 0) @@ -402,9 +402,9 @@ func getSignalsFromOtelcolConfig(otelcolConfigContent string) ([]common.Observab return signals, nil } -func getCommonProcessorsByTier(tier common.OdigosTier) []string { +func getCommonProcessors(disableNameProcessor bool) []string { processors := []string{"batch"} - if tier != common.OnPremOdigosTier { + if !disableNameProcessor { processors = append(processors, "odigosresourcename") } processors = append(processors, "resource", "resourcedetection", "odigostrafficmetrics") diff --git a/autoscaler/controllers/datacollection/root.go b/autoscaler/controllers/datacollection/root.go index 8a484e197..0ad92b35e 100644 --- a/autoscaler/controllers/datacollection/root.go +++ b/autoscaler/controllers/datacollection/root.go @@ -5,7 +5,6 @@ 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" @@ -19,7 +18,7 @@ const ( syncDaemonsetRetry = 3 ) -func Sync(ctx context.Context, c client.Client, scheme *runtime.Scheme, imagePullSecrets []string, odigosVersion string, tier common.OdigosTier) error { +func Sync(ctx context.Context, c client.Client, scheme *runtime.Scheme, imagePullSecrets []string, odigosVersion string, disableNameProcessor bool) error { logger := log.FromContext(ctx) var instApps odigosv1.InstrumentedApplicationList @@ -52,16 +51,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, tier) + return syncDataCollection(&instApps, &dests, &processors, &dataCollectionCollectorGroup, ctx, c, scheme, imagePullSecrets, odigosVersion, disableNameProcessor) } 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, tier common.OdigosTier) error { + scheme *runtime.Scheme, imagePullSecrets []string, odigosVersion string, disableNameProcessor bool) error { logger := log.FromContext(ctx) logger.V(0).Info("Syncing data collection") - _, err := SyncConfigMap(instApps, dests, processors, dataCollection, ctx, c, scheme, tier) + _, err := SyncConfigMap(instApps, dests, processors, dataCollection, ctx, c, scheme, disableNameProcessor) if err != nil { logger.Error(err, "Failed to sync config map") return err diff --git a/autoscaler/controllers/instrumentedapplication_controller.go b/autoscaler/controllers/instrumentedapplication_controller.go index d7cb43104..25e21793d 100644 --- a/autoscaler/controllers/instrumentedapplication_controller.go +++ b/autoscaler/controllers/instrumentedapplication_controller.go @@ -21,7 +21,6 @@ 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" @@ -31,10 +30,10 @@ import ( // InstrumentedApplicationReconciler reconciles a InstrumentedApplication object type InstrumentedApplicationReconciler struct { client.Client - Scheme *runtime.Scheme - ImagePullSecrets []string - OdigosVersion string - OdigosTier common.OdigosTier + Scheme *runtime.Scheme + ImagePullSecrets []string + OdigosVersion string + DisableNameProcessor bool } //+kubebuilder:rbac:groups=odigos.io,resources=instrumentedapplications,verbs=get;list;watch;create;update;patch;delete @@ -52,7 +51,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, r.OdigosTier) + err := datacollection.Sync(ctx, r.Client, r.Scheme, r.ImagePullSecrets, r.OdigosVersion, r.DisableNameProcessor) if err != nil { return ctrl.Result{}, err } diff --git a/autoscaler/controllers/processor_controller.go b/autoscaler/controllers/processor_controller.go index a73fce7ed..2443b19ff 100644 --- a/autoscaler/controllers/processor_controller.go +++ b/autoscaler/controllers/processor_controller.go @@ -6,7 +6,6 @@ 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" @@ -15,10 +14,10 @@ import ( type ProcessorReconciler struct { client.Client - Scheme *runtime.Scheme - ImagePullSecrets []string - OdigosVersion string - OdigosTier common.OdigosTier + Scheme *runtime.Scheme + ImagePullSecrets []string + OdigosVersion string + DisableNameProcessor bool } func (r *ProcessorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) { @@ -31,7 +30,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, r.OdigosTier) + err = datacollection.Sync(ctx, r.Client, r.Scheme, r.ImagePullSecrets, r.OdigosVersion, r.DisableNameProcessor) if err != nil { return ctrl.Result{}, err } diff --git a/autoscaler/main.go b/autoscaler/main.go index 6e6d052a5..e4544e56f 100644 --- a/autoscaler/main.go +++ b/autoscaler/main.go @@ -29,8 +29,6 @@ import ( appsv1 "k8s.io/api/apps/v1" "sigs.k8s.io/controller-runtime/pkg/client" - k8sClient "github.com/odigos-io/odigos/k8sutils/pkg/client" - k8sUtils "github.com/odigos-io/odigos/k8sutils/pkg/utils" "sigs.k8s.io/controller-runtime/pkg/cache" "github.com/go-logr/zapr" @@ -165,15 +163,11 @@ func main() { os.Exit(1) } - client, err := k8sClient.GetK8sClientset() - if err != nil { - setupLog.Error(err, "unable to create k8s clientset") - } - - tier, err := k8sUtils.GetCurrentOdigosTier(context.Background(), odigosNs, client) - if err != nil { - setupLog.Error(err, "unable to get current odigos tier") - } + // The name processor is used to transform device ids injected with the virtual device, + // to service names and k8s attributes. + // it is not needed for eBPF instrumentation or OpAMP implementations. + // at the time of writing (2024-10-22) only dotnet and java native agent are using the name processor. + _, disableNameProcessor := os.LookupEnv("DISABLE_NAME_PROCESSOR") if err = (&controllers.DestinationReconciler{ Client: mgr.GetClient(), @@ -186,31 +180,31 @@ func main() { } if err = (&controllers.ProcessorReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - ImagePullSecrets: imagePullSecrets, - OdigosVersion: odigosVersion, - OdigosTier: tier, + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + ImagePullSecrets: imagePullSecrets, + OdigosVersion: odigosVersion, + DisableNameProcessor: disableNameProcessor, }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "Processor") os.Exit(1) } if err = (&controllers.CollectorsGroupReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - ImagePullSecrets: imagePullSecrets, - OdigosVersion: odigosVersion, - OdigosTier: tier, + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + ImagePullSecrets: imagePullSecrets, + OdigosVersion: odigosVersion, + DisableNameProcessor: disableNameProcessor, }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "CollectorsGroup") os.Exit(1) } if err = (&controllers.InstrumentedApplicationReconciler{ - Client: mgr.GetClient(), - Scheme: mgr.GetScheme(), - ImagePullSecrets: imagePullSecrets, - OdigosVersion: odigosVersion, - OdigosTier: tier, + Client: mgr.GetClient(), + Scheme: mgr.GetScheme(), + ImagePullSecrets: imagePullSecrets, + OdigosVersion: odigosVersion, + DisableNameProcessor: disableNameProcessor, }).SetupWithManager(mgr); err != nil { setupLog.Error(err, "unable to create controller", "controller", "InstrumentedApplication") os.Exit(1) diff --git a/cli/cmd/resources/autoscaler.go b/cli/cmd/resources/autoscaler.go index c6e99ba96..027553dcf 100644 --- a/cli/cmd/resources/autoscaler.go +++ b/cli/cmd/resources/autoscaler.go @@ -2,6 +2,7 @@ package resources import ( "context" + "slices" "github.com/odigos-io/odigos/cli/cmd/resources/resourcemanager" "github.com/odigos-io/odigos/cli/pkg/containers" @@ -393,7 +394,18 @@ func NewAutoscalerLeaderElectionRoleBinding(ns string) *rbacv1.RoleBinding { } } -func NewAutoscalerDeployment(ns string, version string, imagePrefix string, imageName string) *appsv1.Deployment { +func NewAutoscalerDeployment(ns string, version string, imagePrefix string, imageName string, disableNameProcessor bool) *appsv1.Deployment { + + optionalEnvs := []corev1.EnvVar{} + + if disableNameProcessor { + // temporary until we migrate java and dotnet to OpAMP + optionalEnvs = append(optionalEnvs, corev1.EnvVar{ + Name: "DISABLE_NAME_PROCESSOR", + Value: "true", + }) + } + dep := &appsv1.Deployment{ TypeMeta: metav1.TypeMeta{ Kind: "Deployment", @@ -435,7 +447,7 @@ func NewAutoscalerDeployment(ns string, version string, imagePrefix string, imag "--metrics-bind-address=127.0.0.1:8080", "--leader-elect", }, - Env: []corev1.EnvVar{ + Env: append([]corev1.EnvVar{ { Name: "OTEL_SERVICE_NAME", Value: AutoScalerServiceName, @@ -448,7 +460,7 @@ func NewAutoscalerDeployment(ns string, version string, imagePrefix string, imag }, }, }, - }, + }, optionalEnvs...), EnvFrom: []corev1.EnvFromSource{ { ConfigMapRef: &corev1.ConfigMapEnvSource{ @@ -528,6 +540,9 @@ func NewAutoScalerResourceManager(client *kube.Client, ns string, config *common func (a *autoScalerResourceManager) Name() string { return "AutoScaler" } func (a *autoScalerResourceManager) InstallFromScratch(ctx context.Context) error { + + disableNameProcessor := slices.Contains(a.config.Profiles, "disable-name-processor") || slices.Contains(a.config.Profiles, "kratos") + resources := []client.Object{ NewAutoscalerServiceAccount(a.ns), NewAutoscalerRole(a.ns), @@ -535,7 +550,7 @@ func (a *autoScalerResourceManager) InstallFromScratch(ctx context.Context) erro NewAutoscalerClusterRole(), NewAutoscalerClusterRoleBinding(a.ns), NewAutoscalerLeaderElectionRoleBinding(a.ns), - NewAutoscalerDeployment(a.ns, a.odigosVersion, a.config.ImagePrefix, a.config.AutoscalerImage), + NewAutoscalerDeployment(a.ns, a.odigosVersion, a.config.ImagePrefix, a.config.AutoscalerImage, disableNameProcessor), } return a.client.ApplyResources(ctx, a.config.ConfigVersion, resources) } diff --git a/cli/cmd/resources/profiles.go b/cli/cmd/resources/profiles.go index 2d70f6f8a..8097fb39e 100644 --- a/cli/cmd/resources/profiles.go +++ b/cli/cmd/resources/profiles.go @@ -65,15 +65,19 @@ var ( ProfileName: common.ProfileName("code-attributes"), ShortDescription: "Record span attributes in 'code' namespace where supported", } + disableNameProcessorProfile = Profile{ + ProfileName: common.ProfileName("disable-name-processor"), + ShortDescription: "If not using dotnet or java native instrumentations, disable the name processor which is not needed", + } kratosProfile = Profile{ ProfileName: common.ProfileName("kratos"), ShortDescription: "Bundle profile that includes db-payload-collection, semconv, category-attributes, copy-scope, hostname-as-podname, java-native-instrumentations, code-attributes, query-operation-detector", - Dependencies: []common.ProfileName{"db-payload-collection", "semconv", "category-attributes", "copy-scope", "hostname-as-podname", "java-native-instrumentations", "code-attributes", "query-operation-detector"}, + Dependencies: []common.ProfileName{"db-payload-collection", "semconv", "category-attributes", "copy-scope", "hostname-as-podname", "java-native-instrumentations", "code-attributes", "query-operation-detector", "disableNameProcessorProfile"}, } ) func GetAvailableCommunityProfiles() []Profile { - return []Profile{semconvUpgraderProfile, copyScopeProfile} + return []Profile{semconvUpgraderProfile, copyScopeProfile, disableNameProcessorProfile} } func GetAvailableOnPremProfiles() []Profile {