-
Notifications
You must be signed in to change notification settings - Fork 416
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
Support trigger via CloudEvents #1439
Comments
We use gitea as SCM provider, so this includes some values for deploying gitea on the IBM cloud cluster. Repo can be cloned anonymously but anything else requires login. Tekton triggers and pipeline are going to be used, in combination with a new tool, "cdeventer", to react to webhook/events and produce cdevents. We can use vanilla Tekton here so pretty much just install the components for now. The Tekton dashboard is handy for the demo, and it's deployed behind an oauth-proxy to secure it via GitHub login. cdeventer itself is a controller plus tekton resources. The controller for now is added on the cluster using ko, and it's not yet included in this commit. The Tekton resources are developed in the POC and will be copied over to cdeventer later on to make the more reusable. The sink for CDEvents is a CloudEvent broker provided by Knative with its in-memory channel implementation. Knative triggers are used to define subscriptions and get CDEvents to the interested parties. The flow to produce CDEvent for now goes as follows: - demo developer merges a PR in gitea - webhook goes to an event listener in the tekton-ci namespace - the tekton trigger/binding extracts the data required for the change CDEvent from the webhook headers and payload - the tekton trigger template creates a "Run" i.e. a custom task run with the data for the CDEvent - the cdeventer custom task reconciler reconciles the "Run". It uses the new go-sdk to build, validate and send a CDEvent to the CloudEvents broker Now, to consume / display the CDEvent, the flows for now is: - an all catching knative trigger gets the CDEvent to a different Tekton event-listener, el-events, in the default namespace - *note* the knative broker must be set to 0 retries because of tektoncd/triggers#1439 - A Tekton trigger matched on CDEvents runs a display pipeline that shows headers and payload of the CDEvent in the Tekton dashboard Signed-off-by: Andrea Frittoli <andrea.frittoli@gmail.com>
We can probably add a cloud event response type behind a opt in flag? |
It sounds good, but I think it should be only for incoming CloudEvents. |
Are you saying we return the current response if the input is not a cloud event? I was thinking we could eventually stabilize on always returning a cloud event? |
I guess we could... I'm not sure if there is any spec about expected replies for a webhook. |
Yeah, there are no expected replies as far as I know (other than the HTTP status code) |
Just to add some context/motivation. This is especially an issue in combination with knatives retry function (https://knative.dev/docs/eventing/event-delivery/). Because of the unexpected response, it is treated as a failure and retried. The retry results in duplicated resources created by triggers. |
I ran into this too, and I had a look at the code... https://github.com/tektoncd/triggers/blob/main/pkg/sink/sink.go#L211-L223 We could detect CloudEvent requests there, and either write the response as JSON, or, as a CloudEvent message |
I think the response is JSON today, but there are no CloudEvents headers, so it's rejected by the broker |
That's why we'd write it as a CloudEvent message (using the cloudevents code) which would set the response correctly. |
I had a crack at this earlier this morning main...bigkevmcd:triggers:cloudevents-triggers it needs a bit of tidying but the test passes. |
I make extensive use of triggering pipelines via cloudevents delivered from knative... so that works... but I'm forced to disable retry since knative thinks all the responses are bogus regardless of the 202 since it responds with JSON that isn't a CE. Doing any of the things in the original topic here works for me, even if guarded by a feature flag. My old discussion on the subject: https://knative.slack.com/archives/C017X0PFC0P/p1652901710903979 |
Issues go stale after 90d of inactivity. /lifecycle stale Send feedback to tektoncd/plumbing. |
/remove-lifecycle stale |
Issues go stale after 90d of inactivity. /lifecycle stale Send feedback to tektoncd/plumbing. |
/remove-lifecycle stale |
@dibyom i think this has been implemented, right? |
There is a implementation related to slack interceptor which also supports http form data as part of this #1548 which is released in Triggers v0.24 @afrittoli does that PR helps ? |
Thanks @savitaashture - that's a nice feature to have, but I don't think it would help with CloudEvents specifically. I believe that has been addressed and solved in #1469 |
Yes, it has been resolved by #1469 by following 1st approach. I don't see a strong need for disabling the response. |
Feature request
Support CloudEvents compliant responses.
I see a few options:
Use case
When the project was started, it was decided to support generic HTTP requests with JSON payload rather than focus specifically on CloudEvents. The current behaviour of triggers is not compliant with the CloudEvents spec though, which makes it hard to use Triggers as a sink for CloudEvents.
When using triggers with Knative broker, the broker checks if the response is a cloud event, or empty, and reports a 502 back otherwise. See the code and the logs from a test cluster:
The text was updated successfully, but these errors were encountered: