Skip to content

Commit

Permalink
Check ignored namespaces (#1368)
Browse files Browse the repository at this point in the history
  • Loading branch information
edeNFed authored Jul 18, 2024
1 parent 4c8b890 commit 53f9de9
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion odiglet/pkg/kube/instrumentation_ebpf/pods.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package instrumentation_ebpf
import (
"context"

odigosv1 "github.com/odigos-io/odigos/api/odigos/v1alpha1"

"github.com/odigos-io/odigos/common"
"github.com/odigos-io/odigos/k8sutils/pkg/env"
"github.com/odigos-io/odigos/odiglet/pkg/ebpf"
Expand All @@ -22,10 +24,27 @@ type PodsReconciler struct {
Directors ebpf.DirectorsMap
}

func (p *PodsReconciler) isNamespaceIgnored(ctx context.Context, ns string) bool {
var odigosConfig odigosv1.OdigosConfiguration
err := p.Client.Get(ctx, client.ObjectKey{Name: "odigos-config", Namespace: env.GetCurrentNamespace()}, &odigosConfig)
if err != nil {
return false
}

ignoredNamespaces := odigosConfig.Spec.IgnoredNamespaces
for _, ignoredNamespace := range ignoredNamespaces {
if ignoredNamespace == ns {
return true
}
}

return false
}

func (p *PodsReconciler) Reconcile(ctx context.Context, request ctrl.Request) (ctrl.Result, error) {
logger := log.FromContext(ctx)

if request.Namespace == env.GetCurrentNamespace() {
if request.Namespace == env.GetCurrentNamespace() || p.isNamespaceIgnored(ctx, request.Namespace) {
return ctrl.Result{}, nil
}

Expand Down

0 comments on commit 53f9de9

Please sign in to comment.