Add Choice CRD#1529
Conversation
|
Hi @lionelvillard. Thanks for your PR. I'm waiting for a knative member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
Removing WIP. The limitations have been captured in the design document and can be addressed in other PRs. |
|
/ok-to-test |
c7479bd to
95b6a80
Compare
|
@vaikas-google can you take a look at this? |
vaikas
left a comment
There was a problem hiding this comment.
Thanks and my most sincere apologies for this having taken sooooo long... life... 😞
Here's some thoughts and questions about the shape of the API while I'm trying to understand all the everythings going on here.
|
|
||
| // +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object | ||
|
|
||
| // ChoiceList is a collection of Sequences. |
There was a problem hiding this comment.
nit: looks like copy / paste error here?
| - name: Reason | ||
| type: string | ||
| JSONPath: ".status.conditions[?(@.type==\"Ready\")].reason" | ||
| - name: Hostname |
There was a problem hiding this comment.
should we be trying to use the URL now that it's seemingly mature in the v1beta1 of serving?
| // ChannelTemplate specifies which Channel CRD to use | ||
| ChannelTemplate ChannelTemplateSpec `json:"channelTemplate"` | ||
|
|
||
| // Reply is a Reference to where the result of the last Subscriber of a given branch gets sent to. |
There was a problem hiding this comment.
The comment 'a given branch' would imply that this is per branch, but it seems like by setting this each branch will "terminate" here. Is this really what we want, or should the reply be maybe overrideable at the Case level and if not specified, use the Reply here and then all Cases will terminate to this Reply?
There was a problem hiding this comment.
in the design document I described both cases (Single vs multiple prongs section) as being mutually exclusive, either use a global Reply or per branch. I don't see any problems to have the case reply overriding the global reply, wrt. to composability for instance. Also error-handling will be much easier to implement.
| // Reconciling choice is pretty straightforward, it does the following things: | ||
| // 1. Create a channel fronting the whole choice | ||
| // 2. For each of the Cases: | ||
| // 2.1 create a Subscription to the previous Channel and subscribe the filter |
There was a problem hiding this comment.
"previous Channel" -> channel in step 1? As in, for Sequence it made sense to refer to previous channel, but here there's only one channel fronting the choice, then all Cases subscribe to it?
There was a problem hiding this comment.
yup bad comment.
| // 1. Create a channel fronting the whole choice | ||
| // 2. For each of the Cases: | ||
| // 2.1 create a Subscription to the previous Channel and subscribe the filter | ||
| // 2.2 create a Subscription to the filter Channel and subcribe the subscriber |
There was a problem hiding this comment.
can't step 4 be done here and set the reply as part of this step?
There was a problem hiding this comment.
... time passes... looks like there's no step 4 and it's instead done as part of the step 2.2 above?
| // * Conditions - the latest available observations of a resource's current state. | ||
| duckv1beta1.Status `json:",inline"` | ||
|
|
||
| // ChoiceStatuses is an array of corresponding Subscription statuses. |
There was a problem hiding this comment.
Wonder if it would be better to have a ChoiseCaseStatus and then an array here. I think it's little more complicated than just subscriptionstatus/channelstatus, because each Case actually has 2 subscriptions? It has one that subscribes the filter to the "ingress" channel, and then there's a subscription created from filter (and I'd assume a channel between the filter / "actual" subscriber), so at the very least it seems like you'd need to represent state of 2 subscriptions in each CaseStatus as well as probably one channel (between filter / "actual" subscription) and maybe a Channel after the "actual" subscriber that a Reply gets subscribed to?
There was a problem hiding this comment.
yup agree. The flat array was just to get started.
There was a problem hiding this comment.
We might also want to propagate the Reply status to make it clear which one has been applied (global reply or case reply).
e4e0d87 to
4e259bd
Compare
vaikas
left a comment
There was a problem hiding this comment.
one small change (unless you want to add the default channel behaviour now?)
| Cases []ChoiceCase `json:"cases"` | ||
|
|
||
| // ChannelTemplate specifies which Channel CRD to use | ||
| ChannelTemplate eventingduckv1alpha1.ChannelTemplateSpec `json:"channelTemplate"` |
There was a problem hiding this comment.
Take a look at:
#1569
Might as well add the default channel support to make these easier to use.
TODO & issue would be fine for now if you don't want to add it. But I'd at least change this to a pointer for now to make the transition easier.
| // FilterSubscriptionStatus corresponds to the filter subscription status. | ||
| FilterSubscriptionStatus ChoiceSubscriptionStatus `json:"filterSubscriptionStatus"` | ||
|
|
||
| // ChannelStatus corresponds to the filter channel status. |
| var _ runtime.Object = (*Choice)(nil) | ||
| var _ webhook.GenericCRD = (*Choice)(nil) | ||
|
|
||
| type ChoiceSpec struct { |
There was a problem hiding this comment.
Please file a tracking bug for documenting the usage and examples. Feel free to use something like this as a starting point:
https://github.com/knative/docs/blob/master/docs/eventing/sequence.md
Also, there's a pointer to a simple transformer that might be useful to use in the examples:
instead of step numbers, you could bake in the "branch name" or something:
https://github.com/vaikas-google/transformer
|
The following is the coverage report on pkg/.
|
| // with a reference to the Addressable duck type. If the resource does not meet this contract, | ||
| // it will be reflected in the Subscription's status. | ||
| // +optional | ||
| Reply *corev1.ObjectReference `json:"reply,omitempty"` |
There was a problem hiding this comment.
Does it make sense for choice to support multi-leg Subscriber/Reply?
There was a problem hiding this comment.
I was going back and forth on this one and I think one good use case is error-handling, which can be done by having one leg sending the reply to an error sink when the event is an error (TBD).
vaikas
left a comment
There was a problem hiding this comment.
Could you create an issue to add an e2e test for choice, like:
https://github.com/knative/eventing/blob/master/test/e2e/sequence_test.go
| // provided, until one pass (returns true) | ||
| Cases []ChoiceCase `json:"cases"` | ||
|
|
||
| // ChannelTemplate specifies which Channel CRD to use |
There was a problem hiding this comment.
Thanks for changing this, could you also add a comment here about the default behaviour since it's an API file.
|
/approve |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: lionelvillard, vaikas-google The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
|
/lgtm I would like to play with this, there might be changes in the future but given our limitations today I think this is a good starting spot. |
Signed-off-by: Matthias Wessendorf <mwessend@redhat.com> Co-authored-by: Matthias Wessendorf <mwessend@redhat.com>
Signed-off-by: red-hat-konflux-kflux-prd-rh02 <190377777+red-hat-konflux-kflux-prd-rh02[bot]@users.noreply.github.com> Co-authored-by: red-hat-konflux-kflux-prd-rh02[bot] <190377777+red-hat-konflux-kflux-prd-rh02[bot]@users.noreply.github.com>
Fixes #1525
This PR only provides the wiring shown in the design document. Currently there is no guarantee that only one branch will be executed. It's up to the user to provide "proper" filter functions.
(moved open issues to design document)
Proposed Changes
Release Note