Skip to content
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

Merged

Conversation

christophd
Copy link
Contributor

@christophd christophd commented Jun 6, 2024

Release Note

fix(#5537): Support filter attributes other than event type
fix(#5529): Allows empty filter to consume the full event stream
fix(#5446): Knative Trigger creation is only based on event type attribute
fix(#5577): Consistently support "cloudEventsType" property in Pipes source/sink

Copy link
Contributor

github-actions bot commented Jun 6, 2024

✔️ Unit test coverage report - coverage increased from 39.6% to 39.7% (+0.1%)

Copy link
Contributor

@squakez squakez left a 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/trait/knative_test.go Outdated Show resolved Hide resolved
pkg/trait/knative_test.go Outdated Show resolved Hide resolved
}, nil
}

if len(filterExpressions) > 0 {
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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

@squakez
Copy link
Contributor

squakez commented Jun 6, 2024

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.

@christophd
Copy link
Contributor Author

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

@squakez
Copy link
Contributor

squakez commented Jun 6, 2024

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.

@christophd christophd force-pushed the issue/5537/improve-knative-trigger-filter branch from d98000c to 10b7916 Compare June 6, 2024 18:05
Copy link
Contributor

github-actions bot commented Jun 6, 2024

✔️ Unit test coverage report - coverage increased from 39.6% to 39.7% (+0.1%)

@christophd christophd force-pushed the issue/5537/improve-knative-trigger-filter branch 2 times, most recently from 6c5a6be to 656ddb3 Compare June 7, 2024 09:42
Copy link
Contributor

github-actions bot commented Jun 7, 2024

✔️ Unit test coverage report - coverage increased from 39.8% to 39.9% (+0.1%)

@christophd christophd force-pushed the issue/5537/improve-knative-trigger-filter branch from 656ddb3 to c62573e Compare June 7, 2024 11:52
Copy link
Contributor

github-actions bot commented Jun 7, 2024

✔️ Unit test coverage report - coverage increased from 39.8% to 39.9% (+0.1%)

@christophd christophd force-pushed the issue/5537/improve-knative-trigger-filter branch from c62573e to 7494735 Compare June 7, 2024 13:22
Copy link
Contributor

github-actions bot commented Jun 7, 2024

✔️ Unit test coverage report - coverage increased from 39.8% to 39.9% (+0.1%)

@christophd christophd force-pushed the issue/5537/improve-knative-trigger-filter branch from 7494735 to d2a03df Compare June 7, 2024 14:14
Copy link
Contributor

github-actions bot commented Jun 7, 2024

✔️ Unit test coverage report - coverage increased from 39.8% to 39.9% (+0.1%)

@christophd christophd force-pushed the issue/5537/improve-knative-trigger-filter branch from d2a03df to 18e4941 Compare June 7, 2024 18:03
Copy link
Contributor

github-actions bot commented Jun 7, 2024

✔️ Unit test coverage report - coverage increased from 39.8% to 39.9% (+0.1%)

@christophd christophd force-pushed the issue/5537/improve-knative-trigger-filter branch from 18e4941 to b0cd014 Compare June 10, 2024 08:25
@christophd
Copy link
Contributor Author

@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?

@squakez
Copy link
Contributor

squakez commented Jun 10, 2024

Please, verify if @lburgazzoli can provide his thoughts about this before going ahead. Thanks.

@lburgazzoli
Copy link
Contributor

Does it also relate to #3378 ?

@christophd
Copy link
Contributor Author

@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.

@lburgazzoli
Copy link
Contributor

Since the Pipe is an higher level resource, I think it is fine if it has access to any of the spec properties of the Integration CRD like if it were any other client (in fact, in the KameletBinding reconciler has been originally implemented as a dedicated operator, and then merged in the camel-k operator).

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:

  • the fact that there is no subgroup for filter elements may be a little bit confusing as you don’t really know which properties are part of the filter and which are not. i.e. I recall one can add name property and that property would be used to determine the name of the broker if not provided in the ref
  • about the knative trait, the same as above can apply as there (maybe) are some conflicting properties maybe ? i.e. what happen if you set a filter for a non broker resource ?

@christophd
Copy link
Contributor Author

the fact that there is no subgroup for filter elements may be a little bit confusing as you don’t really know which properties are part of the filter and which are not. i.e. I recall one can add name property and that property would be used to determine the name of the broker if not provided in the ref

true, I will add this to the documentation so the user has an idea how and what properties are set as a trigger filter

@christophd
Copy link
Contributor Author

about the knative trait, the same as above can apply as there (maybe) are some conflicting properties maybe ? i.e. what happen if you set a filter for a non broker resource?

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
@christophd christophd force-pushed the issue/5537/improve-knative-trigger-filter branch from b0cd014 to a7e8abe Compare June 10, 2024 18:05
@christophd christophd merged commit d2605bd into apache:main Jun 11, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants