knative / eventing

Event-driven application platform for Kubernetes
https://knative.dev/docs/eventing
Apache License 2.0
1.41k stars 590 forks source link

Auto Enabled Events only show up for InMemory channel #7154

Closed matzew closed 1 year ago

matzew commented 1 year ago

Describe the bug

Create a broker like:

apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
  namespace: default
  name: my-broker

and than send some random event to it, like:

kn-event-linux-amd64 send \
  --to Broker:eventing.knative.dev/v1:my-broker\
  --type com.corp.integration.warning \
  -f message="fooss"

You will not see an EventType for the broker: just the channel. However, the channel is just an implementation detail, and is OK that it is listed there, on the ingress, but for sure it should also show this for the Broker.

Result:

k get eventtypes.eventing.knative.dev -A  
NAMESPACE   NAME                                  TYPE                           SOURCE            SCHEMA   REFERENCE NAME          REFERENCE KIND    DESCRIPTION                             READY   REASON
default     et-my-broker-kne-trigger-y29tlmnvcn   com.corp.integration.warning   kn-event/v1.9.0            my-broker-kne-trigger   InMemoryChannel   Event Type auto-created by controller   True    
matzew commented 1 year ago

Actually:

If events are routed to a channel created/owned by the broker controller, we should not create these event types

dsimansk commented 1 year ago

@matzew pls do you have a quick hint where is the routing happening to check if we can infer the ownership?

Cali0707 commented 1 year ago

@dsimansk are you working on this? If not, I can take it :)

dsimansk commented 1 year ago

@Cali0707 go ahead I was just poking around, but haven't found a good starting point. :)

Cali0707 commented 1 year ago

/assign

Cali0707 commented 1 year ago

@matzew it looks like this is happening because the TypeMeta is not properly set on the Broker object used in the ingress_handler.go. The TypeMeta is always initially set correctly, however after the first call to getBroker https://github.com/knative/eventing/blob/7636997cd0b81d3846948726fa5d7b9a41c584e0/pkg/broker/ingress/ingress_handler.go#L126-L130 the Broker object stored in the indexer changes to have no TypeMeta set, so when we access the broker object when creating events there is no TypeMeta anymore. Also, on subsequent http requests, there is no TypeMeta - only on the first request it is set.

Temporarily, we can fix this by just hardcoding the TypeMeta, but I think we should try and figure out what the problem is - WDYT?