-
Notifications
You must be signed in to change notification settings - Fork 345
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
fix: Improve Knative trigger filter #5597
fix: Improve Knative trigger filter #5597
Conversation
✔️ Unit test coverage report - coverage increased from 39.6% to 39.7% (+0.1%) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have some design doubt about certain coupling we're adding. I need to review this deeply to understand what's the design implication of such change.
pkg/util/bindings/knative_ref.go
Outdated
}, nil | ||
} | ||
|
||
if len(filterExpressions) > 0 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure it is a good way to configure it. The binding should know nothing about traits and its configuration I think.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the binding is supposed to adjust/configure the traits by design as it is part of the binding interface API and the trait config set by the binding explicitly gets merged into the integration traits.
See https://github.com/apache/camel-k/blob/main/pkg/util/bindings/api.go#L41
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think the original idea was to use a way to represent certain options in order to later merge in the Integration [1] (ie, knative trait only). However, this changed when we have done the trait refactoring, creating a direct dependency between traits and bindings [2]. This was in fact only used in KnativeURI translator so far. I have the feeling that we should rework this part and find a different approach instead of extending a potential wrong design. What I mean is that the "trait" concept is an Integration thing and extending it widely creates coupling we can regret in the future. @lburgazzoli wdyt?
[1] 19b66cf#diff-abb6a6ae31c506ba2b634a29eba8930cd19766cdec4d7d3aae43fbc3b4a08996
[2] a92aaa4#diff-abb6a6ae31c506ba2b634a29eba8930cd19766cdec4d7d3aae43fbc3b4a08996
BTW, I think it would be wiser to split each issue you're fixing in separate PR. Maybe some of them can be merged straight away. If there is some code change in common for each, maybe you can start with a first PR and then issue any dependant PR once the others are approved and merged. |
Sorry, for the bigger PR. Yes, I thought about splitting into multiple PRs but it all somehow touches the same bits so I kept it in one single PR. Please let me know if it works for you as I am having a look into the failing E2E tests right now |
No problem. I say more in the interest to maintain separate discussions and let the other fixes to go through independently. |
d98000c
to
10b7916
Compare
✔️ Unit test coverage report - coverage increased from 39.6% to 39.7% (+0.1%) |
6c5a6be
to
656ddb3
Compare
✔️ Unit test coverage report - coverage increased from 39.8% to 39.9% (+0.1%) |
656ddb3
to
c62573e
Compare
✔️ Unit test coverage report - coverage increased from 39.8% to 39.9% (+0.1%) |
c62573e
to
7494735
Compare
✔️ Unit test coverage report - coverage increased from 39.8% to 39.9% (+0.1%) |
7494735
to
d2a03df
Compare
✔️ Unit test coverage report - coverage increased from 39.8% to 39.9% (+0.1%) |
d2a03df
to
18e4941
Compare
✔️ Unit test coverage report - coverage increased from 39.8% to 39.9% (+0.1%) |
18e4941
to
b0cd014
Compare
@squakez all tests are green now. I have also added some E2E test to verify the different Knative trigger possibilities (e.g. no filter, filter by ce-source and so on) In terms of design considerations I think the binding provider is meant to create/configure the integration from a Pipe that may reference other K8s resources. The binding provider translates these resource references into Camel components and the YAML route DSL that is being used in the integration. The traits are part of the integration so the binding provider has access to it, which is not a new design introduced in this PR. We can open a new issue to discuss this current design if you want. WDYT? |
Please, verify if @lburgazzoli can provide his thoughts about this before going ahead. Thanks. |
Does it also relate to #3378 ? |
@lburgazzoli this PR does not include the support for the extended triggers in Knative. At the moment the extended triggers are experimental and we would need more logic on the Knative trait to support the extended filters for the trigger. But yes, the Pipe configuring the extended Knative triggers via traits is one possible option. |
Since the For the specific question about the fact that a binding resolver has access to the traits, then I think it is perfectly fine as the resolver should be able to influence how an integration behave. In term of code, I don't know if there is any better, less coupled option, but given it is already the way it works as today, then I'm fine with the implementation. The only two notes I can add are about UX, probably something not strictly related to this PR but, let me write them down here:
|
true, I will add this to the documentation so the user has an idea how and what properties are set as a trigger filter |
I have checked in the code and Camel K will create the trigger only when using the broker resource as a source. when referencing a Knative channel resource for instance Camel K will not create the trigger and it is assumed that the channel and the trigger are present already. So setting the trigger filter on the trait is only valid for broker type events. This is the result of us having a single Knative trait config for multiple Knative resources (broker, channel, service) as a source/sink. Again, this needs to be made clear in the documentation. I will take care of it (probably in a separate PR) |
- Fixes apache#5537: Support filter attributes other than event type (e.g. source, subject, extensions) - Fixes apache#5529: Allows empty filter to consume the full event stream - Fixes apache#5446: Knative Trigger creation is only based on event type attribute - Fixes apache#5577: Consistently support "cloudEventsType" property in Pipes source/sink - Update documentation and improve Knative Kamelet/Pipe user guide
b0cd014
to
a7e8abe
Compare
type
#5537:Support filter attributes other than event type (e.g. source, subject, extensions)
Allows empty filter to consume the full event stream
Knative Trigger creation is only based on event type attribute
Consistently support "cloudEventsType" property in Pipes source/sink
Release Note