Problem
We need to provide Event Consumers with a mechanism to discover what event types they can consume from the eventing mesh.
Persona:
Event Consumer
Exit Criteria
Executing kubectl get eventtypes -n <namespace> returns the event types available for consumption in that particular namespace.
Time Estimate (optional):
2 or 3 weeks. It will depend on how fast the design conversations move forward.
Do you have a suggestion for how Kn gets this information? Does each Kn EventSource have built-in knowledge of the event types coming from its event producers? Does it query the event producers periodically?
In my opinion there are couple of things here that are at play.
Kn EventSource (CRD) is a Potential Source of events. Unless a Custom Resource is created (aka, CRD is reified and hence a dataplane is established), they are only that, potential events and they should not be listed in the Registry as available because without a configured CR, the events are not available for consumption.
Kn EventSource should publish what event types it is capable of producing. How it generates and how frequent this list is updated, should be discussed in a separate topic (fair?) I've been meaning to create / update an issue talking about the Event Sources in more depth, I'll get to this soon (promise :) )
Now, back to the registry. I think since Trigger is bound to a given Broker (and hence a namespace), a registry should be a list of available event types for that Broker. I can see value being able to list all event types for a given namespace, possibly listing the Broker that is able to provide them. So, at the very least, I could see the above command returning:
eventtype, broker
I think there are use cases obvs for things like source there as well, but at the very least I see the two entries above as necessary for being able to create a trigger without resorting to some other OOB mechanism.
If the registry has the ability to add new event types into it (as an example, just a CRD and creating a new CR to represent event type), then a Broker can be configured to (for example):
So, with those assumptions, one possible solution would be to have the Event Source (when a CR is created), add those events into the Event Registry for the Broker that it has been wired to send those events.
However, I could see also (at least) another mode where the registry would be more complex and in this world, the registry could contain also the list of potential EventTypes and in that case the Source would have to populate all the registries with all the potential EventTypes in the registry, and the Registry would have to have a backpointer to the CRD which can provide those event types. Then when a Trigger is created, Trigger Controller could consult the registry, and if not already configured to emit those events into the specified Broker, could create the CR representing the desired EventTypes. This model gets messy however because in addition to the Trigger spec, there are probably things like credentials that have to be involved here. While we could probably come up with a standard way to define these, I would like to punt on this issue for now.
So the flow that I'm proposing is that there are two high level operations the user performs:
By having a registry that contains available events for bullet 2 above is what this should be aiming to solve.
Caveats:
Unless a Custom Resource is created (aka, CRD is reified and hence a dataplane is established), they are only that, potential events and they should not be listed in the Registry as available because without a configured CR, the events are not available for consumption.
I'm more into this idea but I think it may add more burden to Kn Source developers (I think we call them Receive Adapter authors), as their controllers will need to take care of creating the EventTypes.
Also, what if there are two CRs, e.g, GitHub_sample_1 that listens to pull_requests from user1 repo1, and GitHub_sample_2 that also listens to pull_requests but from user2 repo2. And they are both tied to the same broker. Shall the GitHub source controller create a single EventType pull_request for that broker or two?
In other words, shouldn't the EventType have some sort of 'owner', 'repo' information to be more "accurate"? If it doesn't have that info, by querying the registry, a consumer might think she can consume pull_requests from any GitHub repo, but she can actually consume from only two.
I guess adding that kind of info will blow up the registry.
I'm wondering what are your thoughts @vaikas-google.
Sorry, are you saying that they should be listed in the registry or not by default? I do agree that Source should be part of this, that's what I _tried_ (but poorly) say here:
"
eventtype, broker
I think there are use cases obvs for things like source there as well, but at the very least I see the two entries above as necessary for being able to create a trigger without resorting to some other OOB mechanism."
And yes, in that case, I would expect in this version there to be two event types with two sources in the registry.
Does each Kn EventSource have built-in knowledge of the event types coming from its event producers?
@duglin some Kn Sources have that info. For example, GitHubSource CRD has the list of event types that we can create webhooks for. I also have a PR pending for a BitBucket one, where we also have that list.
If you look at the AWS SQS adapter code, you can see that it only sends "aws.sqs.message" as event type, the CronJob one sends "dev.knative.cronjob.event", and so on.
I guess we might not know for all sources, but for the ones we do, IMO we should try to "standarize" how they advertise their event types, schemas, etc.
Sorry, are you saying that they should be listed in the registry or not by default?
If we are going with the approach of creating the registry entries upon CR instantiation, then I think we should have that "source" information as part of the EventType data type. The downside is that the registry will grow pretty fast.
My preference would be to add source there and add them to the registry when a CR is created. I am not sure I buy the argument that the registry will grow pretty fast, I think that populating all the namespaces with all the possible events would grow faster than only showing the events that have been created subscriptions to :)
I think that populating all the namespaces with all the possible events would grow faster than only showing the events that have been created subscriptions to :)
Valid point, and you are probably right :) I guess I'm envisioning a system where plenty of CRs will be created.
/assign
Some design discussion going on in https://github.com/knative/eventing/pull/1015
If people think it might be better a doc instead of a markup, I can start a doc as well.
Need to give credit to @vaikas-google and @grantr for the good ideas in the proposal. Bad ones are all mine :)
Done with first iteration of Registry!
Most helpful comment
Done with first iteration of Registry!