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

Check ignored namespaces #1368

Merged
merged 2 commits into from
Jul 18, 2024
Merged
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
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
Loading