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

Remove InstrumentedApplication from UI #2128

Closed
wants to merge 2 commits into from
Closed
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
2 changes: 1 addition & 1 deletion cli/cmd/resources/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ In this doc, we'll keep track of the permissions requested across different reso
| UI | "" | pods | get, list, watch | Required for discovering potential destinations and describing application workloads, and for updating collector metrics. |
| UI | apps | deployments, statefulsets, daemonsets | get, list, patch, update | Needed for application instrumentation. |
| UI | apps | replicasets | get, list | Used for describing source and application configurations. |
| UI | odigos.io | instrumentedapplications, instrumentationinstances, instrumentationconfigs | get, list, watch | Used to retrieve and monitor instrumented applications and configurations. |
| UI | odigos.io | instrumentationinstances, instrumentationconfigs | get, list, watch | Used to retrieve and monitor instrumented applications and configurations. |

---

Expand Down
11 changes: 3 additions & 8 deletions cli/cmd/resources/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -235,15 +235,10 @@ func NewUIClusterRole() *rbacv1.ClusterRole {
Resources: []string{"pods"},
Verbs: []string{"get", "list", "watch"},
},
{ // Needed to read Odigos entities
{ // Needed to read and watch Odigos entities
APIGroups: []string{"odigos.io"},
Resources: []string{"instrumentedapplications", "instrumentationinstances", "instrumentationconfigs"},
Verbs: []string{"get", "list"},
},
{ // Needed to watch Odigos entities
APIGroups: []string{"odigos.io"},
Resources: []string{"instrumentedapplications", "instrumentationinstances"},
Verbs: []string{"watch"},
Resources: []string{"instrumentationinstances", "instrumentationconfigs"},
Verbs: []string{"get", "list", "watch"},
},
},
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/endpoints/collector_metrics/watchers.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func runDeleteWatcher(ctx context.Context, cw *deleteWatcher) error {
if err != nil {
return err
}
sourcesWatcher, err := kube.DefaultClient.OdigosClient.InstrumentedApplications("").Watch(ctx, metav1.ListOptions{})
sourcesWatcher, err := kube.DefaultClient.OdigosClient.InstrumentationConfigs("").Watch(ctx, metav1.ListOptions{})
if err != nil {
return err
}
Expand Down Expand Up @@ -124,12 +124,12 @@ func runWatcherLoop(ctx context.Context, w watchers, notifyChan chan<- deleteNot
}
switch event.Type {
case watch.Deleted:
app := event.Object.(*v1alpha1.InstrumentedApplication)
name, kind, err := commonutils.ExtractWorkloadInfoFromRuntimeObjectName(app.Name)
ic := event.Object.(*v1alpha1.InstrumentationConfig)
name, kind, err := commonutils.ExtractWorkloadInfoFromRuntimeObjectName(ic.Name)
if err != nil {
fmt.Printf("error getting workload info: %v\n", err)
}
notifyChan <- deleteNotification{notificationType: source, sourceID: common.SourceID{Kind: kind, Name: name, Namespace: app.Namespace}}
notifyChan <- deleteNotification{notificationType: source, sourceID: common.SourceID{Kind: kind, Name: name, Namespace: ic.Namespace}}
}
}
}
Expand Down
32 changes: 16 additions & 16 deletions frontend/kube/watchers/instrumented_application_watcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ import (
var addedEventBatcher *EventBatcher
var deletedEventBatcher *EventBatcher

func StartInstrumentedApplicationWatcher(ctx context.Context, namespace string) error {
func StartInstrumentationConfigWatcher(ctx context.Context, namespace string) error {
addedEventBatcher = NewEventBatcher(
EventBatcherConfig{
Event: sse.MessageEventAdded,
CRDType: "InstrumentedApplication",
CRDType: "InstrumentationConfig",
SuccessBatchMessageFunc: func(count int, crdType string) string {
return fmt.Sprintf("successfully added %d sources", count)
},
Expand All @@ -32,7 +32,7 @@ func StartInstrumentedApplicationWatcher(ctx context.Context, namespace string)
deletedEventBatcher = NewEventBatcher(
EventBatcherConfig{
Event: sse.MessageEventDeleted,
CRDType: "InstrumentedApplication",
CRDType: "InstrumentationConfig",
SuccessBatchMessageFunc: func(count int, crdType string) string {
return fmt.Sprintf("successfully deleted %d sources", count)
},
Expand All @@ -42,16 +42,16 @@ func StartInstrumentedApplicationWatcher(ctx context.Context, namespace string)
},
)

watcher, err := kube.DefaultClient.OdigosClient.InstrumentedApplications(namespace).Watch(context.Background(), metav1.ListOptions{})
watcher, err := kube.DefaultClient.OdigosClient.InstrumentationConfigs(namespace).Watch(context.Background(), metav1.ListOptions{})
if err != nil {
return fmt.Errorf("error creating watcher: %v", err)
}

go handleInstrumentedApplicationWatchEvents(ctx, watcher)
go handleInstrumentationConfigWatchEvents(ctx, watcher)
return nil
}

func handleInstrumentedApplicationWatchEvents(ctx context.Context, watcher watch.Interface) {
func handleInstrumentationConfigWatchEvents(ctx context.Context, watcher watch.Interface) {
ch := watcher.ResultChan()
defer addedEventBatcher.Cancel()
defer deletedEventBatcher.Cancel()
Expand All @@ -66,30 +66,30 @@ func handleInstrumentedApplicationWatchEvents(ctx context.Context, watcher watch
}
switch event.Type {
case watch.Added:
handleAddedEvent(event.Object.(*v1alpha1.InstrumentedApplication))
handleAddedEvent(event.Object.(*v1alpha1.InstrumentationConfig))
case watch.Deleted:
handleDeletedEvent(event.Object.(*v1alpha1.InstrumentedApplication))
handleDeletedEvent(event.Object.(*v1alpha1.InstrumentationConfig))
}
}
}
}

func handleAddedEvent(app *v1alpha1.InstrumentedApplication) {
name, kind, err := commonutils.ExtractWorkloadInfoFromRuntimeObjectName(app.Name)
func handleAddedEvent(ic *v1alpha1.InstrumentationConfig) {
name, kind, err := commonutils.ExtractWorkloadInfoFromRuntimeObjectName(ic.Name)
if err != nil {
genericErrorMessage(sse.MessageEventAdded, "InstrumentedApplication", "error getting workload info")
genericErrorMessage(sse.MessageEventAdded, "InstrumentationConfig", "error getting workload info")
return
}
namespace := app.Namespace
namespace := ic.Namespace
target := fmt.Sprintf("name=%s&kind=%s&namespace=%s", name, kind, namespace)
data := fmt.Sprintf("InstrumentedApplication %s created", name)
data := fmt.Sprintf("InstrumentationConfig %s created", name)
addedEventBatcher.AddEvent(sse.MessageTypeSuccess, data, target)
}

func handleDeletedEvent(app *v1alpha1.InstrumentedApplication) {
name, _, err := commonutils.ExtractWorkloadInfoFromRuntimeObjectName(app.Name)
func handleDeletedEvent(ic *v1alpha1.InstrumentationConfig) {
name, _, err := commonutils.ExtractWorkloadInfoFromRuntimeObjectName(ic.Name)
if err != nil {
genericErrorMessage(sse.MessageEventDeleted, "InstrumentedApplication", "error getting workload info")
genericErrorMessage(sse.MessageEventDeleted, "InstrumentationConfig", "error getting workload info")
return
}
data := fmt.Sprintf("Source %s deleted successfully", name)
Expand Down
4 changes: 2 additions & 2 deletions frontend/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,9 +318,9 @@ func main() {
}

// Start watchers
err = watchers.StartInstrumentedApplicationWatcher(ctx, "")
err = watchers.StartInstrumentationConfigWatcher(ctx, "")
if err != nil {
log.Printf("Error starting InstrumentedApplication watcher: %v", err)
log.Printf("Error starting InstrumentationConfig watcher: %v", err)
}

err = watchers.StartDestinationWatcher(ctx, flags.Namespace)
Expand Down
8 changes: 1 addition & 7 deletions helm/odigos/templates/ui/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,10 @@ rules:
- apiGroups:
- odigos.io
resources:
- instrumentedapplications
- instrumentationinstances
- instrumentationconfigs
verbs:
- get
- list
- apiGroups:
- odigos.io
resources:
- instrumentedapplications
- instrumentationinstances
verbs:
- watch

Loading