eventing icon indicating copy to clipboard operation
eventing copied to clipboard

New Trigger Filters do not seem to perform any filtering

Open cldfzn opened this issue 1 year ago • 3 comments

Describe the bug When I attempt to use a trigger with the new-trigger-filters feature enabled in the config-features configmap I do not see any filtering and a service attached to the trigger that is echoing the received events shows all events. If I add a filter block with the filters block the filter block takes precedence and filters the events properly. If I have read things correctly, it should not take precedence. I do get reconciliation errors if I put improper syntax in to the filters field though.

apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
  name: example
spec:
  broker: example
  filters:
    - cesql: "type LIKE 'dev.knative.apiserver.resource.%'"

Expected behavior The filter should not forward all events to the service.

knative version: 1.14.0

cldfzn avatar Jun 20 '24 23:06 cldfzn

Hi @cldfzn thanks for reporting this! I've tried to reproduce this with the following test case:

diff --git a/test/rekt/features/new_trigger_filters/feature.go b/test/rekt/features/new_trigger_filters/feature.go
index ee95bab4e..e258341a9 100644
--- a/test/rekt/features/new_trigger_filters/feature.go
+++ b/test/rekt/features/new_trigger_filters/feature.go
@@ -59,6 +59,7 @@ func NewFiltersFeatureSet(installBroker InstallBrokerFunc) *feature.FeatureSet {
 		FilterAttributeWithEmptyFiltersFeature(installBroker),
 		FiltersOverrideAttributeFilterFeature(installBroker),
 		MultipleFiltersFeature(installBroker),
+		CESQLFilterFeature(installBroker),
 	)
 	return &feature.FeatureSet{
 		Name:     "New Trigger Filters",
@@ -536,3 +537,28 @@ func MultipleFiltersFeature(installBroker InstallBrokerFunc) *feature.Feature {
 
 	return f
 }
+
+func CESQLFilterFeature(installBroker InstallBrokerFunc) *feature.Feature {
+	f := feature.NewFeature()
+
+	eventContexts := []CloudEventsContext{
+		{
+			eventType:     "exact.event.type",
+			shouldDeliver: false,
+		},
+		{
+			eventType:     "dev.knative.apiserver.resource.event.type",
+			shouldDeliver: true,
+		},
+	}
+
+	filters := []eventingv1.SubscriptionsAPIFilter{
+		{
+			CESQL: "type LIKE 'dev.knative.apiserver.resource.%'",
+		},
+	}
+
+	createNewFiltersFeature(f, eventContexts, filters, eventingv1.TriggerFilter{}, installBroker)
+
+	return f
+}

However, all of the tests passed when I ran this...

Would you be able to provide the output of kubectl get cm config-features -n knative-eventing -oyaml? Also which broker implementation are you using?

Cali0707 avatar Jun 28 '24 20:06 Cali0707

The broker that supports the new trigger filtering are: MTChannelBasedBroker and Kafka, RabbitMQ broker doesn't yet but we would welcome contributions

cc @ikavgo

pierDipi avatar Jul 04 '24 15:07 pierDipi

This issue is stale because it has been open for 90 days with no activity. It will automatically close after 30 more days of inactivity. Reopen the issue with /reopen. Mark the issue as fresh by adding the comment /remove-lifecycle stale.

github-actions[bot] avatar Oct 03 '24 01:10 github-actions[bot]