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

chore(scheduler): use instrumentation config instead of application #1602

Merged
merged 2 commits into from
Oct 20, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
2 changes: 1 addition & 1 deletion cli/cmd/resources/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ func NewSchedulerClusterRole() *rbacv1.ClusterRole {
"watch",
},
APIGroups: []string{"odigos.io"},
Resources: []string{"instrumentedapplications"},
Resources: []string{"instrumentationconfigs"},
},
},
}
Expand Down
2 changes: 1 addition & 1 deletion helm/odigos/templates/scheduler/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ rules:
- apiGroups:
- odigos.io
resources:
- instrumentedapplications
- instrumentationconfigs
verbs:
- get
- list
Expand Down
2 changes: 1 addition & 1 deletion scheduler/PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ repo: github.com/odigos-io/odigos/scheduler
resources:
- controller: true
domain: odigos.io
kind: InstrumentedApplication
kind: InstrumentationConfig
version: v1alpha1
- controller: true
domain: odigos.io
Expand Down
4 changes: 2 additions & 2 deletions scheduler/controllers/collectorsgroup_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,9 @@ func (r *CollectorsGroupReconciler) Reconcile(ctx context.Context, req ctrl.Requ
}
}

var instApps odigosv1.InstrumentedApplicationList
var instApps odigosv1.InstrumentationConfigList
if err = r.List(ctx, &instApps); err != nil {
logger.Error(err, "failed to list InstrumentedApps")
logger.Error(err, "failed to list InstrumentationConfigs")
return ctrl.Result{}, err
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package controllers

import (
"context"

odigosv1 "github.com/odigos-io/odigos/api/odigos/v1alpha1"
"github.com/odigos-io/odigos/k8sutils/pkg/consts"
"github.com/odigos-io/odigos/k8sutils/pkg/env"
Expand All @@ -14,27 +15,26 @@ import (
"sigs.k8s.io/controller-runtime/pkg/log"
)

// InstrumentedApplicationReconciler reconciles a InstrumentedApplication object
type InstrumentedApplicationReconciler struct {
type InstrumentationConfigReconciler struct {
client.Client
Scheme *runtime.Scheme
ImagePullSecrets []string
OdigosVersion string
}

func (r *InstrumentedApplicationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
func (r *InstrumentationConfigReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
logger := log.FromContext(ctx)
logger.V(0).Info("Reconciling InstrumentedApps")
logger.V(0).Info("Reconciling InstrumentationConfig")

namespace := env.GetCurrentNamespace()

var instrumentedApps odigosv1.InstrumentedApplicationList
err := r.List(ctx, &instrumentedApps)
var instrumentedConfigs odigosv1.InstrumentationConfigList
err := r.List(ctx, &instrumentedConfigs)
if err != nil {
logger.Error(err, "failed to list InstrumentedApplications")
logger.Error(err, "failed to list InstrumentationConfigs")
return ctrl.Result{}, err
}
numberOfInstrumentedApps := len(instrumentedApps.Items)
numberOfInstrumentedApps := len(instrumentedConfigs.Items)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numberOfInstrumentedApps -> numberOfInstrumentationConfigs

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's intentional. Each instrumentation config object represents an app


if numberOfInstrumentedApps == 0 {
if err = utils.DeleteCollectorGroup(ctx, r.Client, namespace, consts.OdigosNodeCollectorCollectorGroupName); err != nil {
Expand Down Expand Up @@ -74,9 +74,8 @@ func (r *InstrumentedApplicationReconciler) Reconcile(ctx context.Context, req c
return ctrl.Result{}, nil
}

// SetupWithManager sets up the controller with the Manager.
func (r *InstrumentedApplicationReconciler) SetupWithManager(mgr ctrl.Manager) error {
func (r *InstrumentationConfigReconciler) SetupWithManager(mgr ctrl.Manager) error {
return ctrl.NewControllerManagedBy(mgr).
For(&odigosv1.InstrumentedApplication{}).
For(&odigosv1.InstrumentationConfig{}).
Complete(r)
}
4 changes: 2 additions & 2 deletions scheduler/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,11 +99,11 @@ func main() {
setupLog.Error(err, "unable to create controller", "controller", "Destination")
os.Exit(1)
}
if err = (&controllers.InstrumentedApplicationReconciler{
if err = (&controllers.InstrumentationConfigReconciler{
Client: mgr.GetClient(),
Scheme: mgr.GetScheme(),
}).SetupWithManager(mgr); err != nil {
setupLog.Error(err, "unable to create controller", "controller", "InstrumentedApplication")
setupLog.Error(err, "unable to create controller", "controller", "InstrumentationConfig")
os.Exit(1)
}
//+kubebuilder:scaffold:builder
Expand Down
Loading