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

Broker eventtype autocreate fixes #7161

Merged
merged 6 commits into from
Aug 24, 2023

Conversation

Cali0707
Copy link
Member

@Cali0707 Cali0707 commented Aug 9, 2023

Fixes #7154

Proposed Changes

  • Add in logic to handler broker missing typemeta
  • Check the owner references on the channel to figure out if eventtypes should be created for the channel or for a broker

Pre-review Checklist

  • At least 80% unit test coverage
  • E2E tests for any new behavior
  • Docs PR for any user-facing impact
  • Spec PR for any new API feature
  • Conformance test for any change to the spec

Release Note

Event Types are now only created once when using a MTChannelBasedBroker.

Signed-off-by: Calum Murray <cmurray@redhat.com>
…e sent to mt channel broker

Signed-off-by: Calum Murray <cmurray@redhat.com>
@knative-prow knative-prow bot requested review from odacremolbap and pierDipi August 9, 2023 20:25
@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2023
@knative-prow knative-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 9, 2023
Signed-off-by: Calum Murray <cmurray@redhat.com>
@knative-prow-robot knative-prow-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2023
@knative-prow knative-prow bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Aug 9, 2023
Signed-off-by: Calum Murray <cmurray@redhat.com>
@knative-prow knative-prow bot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 9, 2023
@Cali0707
Copy link
Member Author

Cali0707 commented Aug 9, 2023

/cc @matzew @dsimansk

@knative-prow knative-prow bot requested review from dsimansk and matzew August 9, 2023 20:34
Signed-off-by: Calum Murray <cmurray@redhat.com>
@codecov
Copy link

codecov bot commented Aug 9, 2023

Codecov Report

Patch coverage: 27.77% and project coverage change: -0.05% ⚠️

Comparison is base (7636997) 77.93% compared to head (3d462ac) 77.89%.
Report is 15 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7161      +/-   ##
==========================================
- Coverage   77.93%   77.89%   -0.05%     
==========================================
  Files         246      246              
  Lines       13200    13214      +14     
==========================================
+ Hits        10288    10293       +5     
- Misses       2390     2400      +10     
+ Partials      522      521       -1     
Files Changed Coverage Δ
pkg/broker/ingress/ingress_handler.go 56.70% <0.00%> (-2.13%) ⬇️
...iler/inmemorychannel/dispatcher/inmemorychannel.go 64.13% <50.00%> (-0.68%) ⬇️

... and 2 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@dsimansk
Copy link
Contributor

/lgtm

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Aug 10, 2023
@Cali0707
Copy link
Member Author

Btw @matzew I'm not 100% sure if the approach I've taken here is going to work for all cases. Because I'm using the owner reference on a channel and verifiying that it is a broker, if a broker creates a channel and then I send events directly to the channel (and not to the broker), the event type will still be registered with the broker as the owner. Do you think this behaviour is okay?

@matzew
Copy link
Member

matzew commented Aug 11, 2023

Do you think this behaviour is okay?

yes, that is OK.

However the event sent should be visible for the broker. Is that still the case?

@Cali0707
Copy link
Member Author

@matzew this is the current behaviour:

kn-event-linux-amd64 send \
  --to Broker:eventing.knative.dev/v1:my-broker \
  --type com.corp.integration.warning \
  -f message="fooss"

kn-event-linux-amd64 send \
  --to InMemoryChannel:messaging.knative.dev/v1:my-broker-kne-trigger \
  --type org.somewhere.error \
  -f message="message"

kubectl get eventtypes.eventing.knative.dev -A
NAMESPACE   NAME                      TYPE                                   SOURCE             SCHEMA   REFERENCE NAME   REFERENCE KIND   DESCRIPTION                             READY   REASON
default     et-my-broker-b3jnlnnvbw   org.somewhere.error                    kn-event/v1.10.0            my-broker        Broker           Event Type auto-created by controller   True    
default     et-my-broker-y29tlmnvcn   com.corp.integration.warning           kn-event/v1.10.0            my-broker        Broker           Event Type auto-created by controller   True    

@matzew
Copy link
Member

matzew commented Aug 22, 2023

@Cali0707 Sorry for getting back late here.

kn-event-linux-amd64 send \
  --to InMemoryChannel:messaging.knative.dev/v1:my-broker-kne-trigger \
  --type org.somewhere.error \
  -f message="message"

when sending it directly to the channel, I'd not expect it to be "reference" for the broker. 🤔

@Cali0707
Copy link
Member Author

Cali0707 commented Aug 22, 2023

when sending it directly to the channel, I'd not expect it to be "reference" for the broker. 🤔

@matzew the way I can currently see us implementing this is by adding a header or CE extension e.g. ce-type-owner-ref. When ce-type-owner-ref is set, we create the event type based on it, and if it is not present then we just use the default owner. So, on the broker ingress we could set this CE extension before passing the event to the channel, but events sent to the channel would not have the extension set.

Does this make sense, or do you have another idea?

@matzew
Copy link
Member

matzew commented Aug 23, 2023

@Cali0707
So, I think we should just completely ignore those, directly sent to the channel URL.

The channel is an IMP detail, and if we have a channel, created by the broker: only because that's how the broker is implemented.

I think an event also directly (as in incorrectly) sent to the channel (instead of the broker), is also not getting out to the sink of the trigger.

Hence, we should just correct the current behavior, described on the bug (which currently puts refernce to IMC, but really is broker).

So, "managed" channel (e.g. by broker) should not do the auto-create

@matzew
Copy link
Member

matzew commented Aug 23, 2023

/hold

@knative-prow knative-prow bot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 23, 2023
Signed-off-by: Calum Murray <cmurray@redhat.com>
@knative-prow knative-prow bot removed the lgtm Indicates that a PR is ready to be merged. label Aug 23, 2023
@Cali0707
Copy link
Member Author

@matzew this now behaves as follows:

kn-event-linux-amd64 send \                   
  --to Broker:eventing.knative.dev/v1:my-broker \      
  --type new.event.type \     
  -f message="message"

kn-event-linux-amd64 send \
  --to InMemoryChannel:messaging.knative.dev/v1:my-broker-kne-trigger \
  --type org.somewhere.error \
  -f message="message"

kn-event-linux-amd64 send \            
  --to Channel:messaging.knative.dev/v1:example-channel \
  --type org.somewhere.error \
  -f message="message"

kubectl get eventtypes.eventing.knative.dev
NAMESPACE   NAME                            TYPE                  SOURCE             SCHEMA   REFERENCE NAME    REFERENCE KIND    DESCRIPTION                             READY   REASON
default     et-example-channel-b3jnlnnvbw   org.somewhere.error   kn-event/v1.10.0            example-channel   InMemoryChannel   Event Type auto-created by controller   True    
default     et-my-broker-bmv3lmv2zw         new.event.type        kn-event/v1.10.0            my-broker         Broker            Event Type auto-created by controller   True    

Where example-channel and my-broker are user created, and the other channel was created by the broker under the hood (and hence did not have an event created).

@Cali0707
Copy link
Member Author

/cc @matzew @Leo6Leo @dsimansk

Copy link
Member

@matzew matzew left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks to tackling this!

/lgtm
/approve

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Aug 24, 2023
@knative-prow
Copy link

knative-prow bot commented Aug 24, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Cali0707, matzew

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@knative-prow knative-prow bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 24, 2023
@matzew
Copy link
Member

matzew commented Aug 24, 2023

/unhold

@knative-prow knative-prow bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 24, 2023
@knative-prow knative-prow bot merged commit 0045fa9 into knative:main Aug 24, 2023
@matzew
Copy link
Member

matzew commented Aug 24, 2023

/cherry-pick release-v1.11

@knative-prow-robot
Copy link
Contributor

@matzew: cannot checkout release-v1.11: error checking out release-v1.11: exit status 1. output: error: pathspec 'release-v1.11' did not match any file(s) known to git

In response to this:

/cherry-pick release-v1.11

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

@Cali0707
Copy link
Member Author

/cherry-pick release-1.11

@knative-prow-robot
Copy link
Contributor

@Cali0707: #7161 failed to apply on top of branch "release-1.11":

Applying: Fixed undefined typemeta on broker in eventtype autocreate
Applying: Fixed autocreate so that only one eventtype is created when events are sent to mt channel broker
Applying: Clean up
Using index info to reconstruct a base tree...
A	eventing-controller.env
A	imc-dispatcher.env
A	mt-broker-ingress.env
Falling back to patching base and 3-way merge...
No changes -- Patch already applied.
Applying: Fixed unit tests
Applying: channel only creates eventtypes if not owned by broker
Using index info to reconstruct a base tree...
M	pkg/reconciler/inmemorychannel/dispatcher/controller.go
M	pkg/reconciler/inmemorychannel/dispatcher/inmemorychannel.go
Falling back to patching base and 3-way merge...
Auto-merging pkg/reconciler/inmemorychannel/dispatcher/inmemorychannel.go
CONFLICT (content): Merge conflict in pkg/reconciler/inmemorychannel/dispatcher/inmemorychannel.go
Auto-merging pkg/reconciler/inmemorychannel/dispatcher/controller.go
CONFLICT (content): Merge conflict in pkg/reconciler/inmemorychannel/dispatcher/controller.go
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0005 channel only creates eventtypes if not owned by broker
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".

In response to this:

/cherry-pick release-1.11

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

Cali0707 added a commit to Cali0707/eventing that referenced this pull request Aug 24, 2023
* Fixed undefined typemeta on broker in eventtype autocreate

Signed-off-by: Calum Murray <cmurray@redhat.com>

* Fixed autocreate so that only one eventtype is created when events are sent to mt channel broker

Signed-off-by: Calum Murray <cmurray@redhat.com>

* Clean up

Signed-off-by: Calum Murray <cmurray@redhat.com>

* Fixed unit tests

Signed-off-by: Calum Murray <cmurray@redhat.com>

* channel only creates eventtypes if not owned by broker

Signed-off-by: Calum Murray <cmurray@redhat.com>

---------

Signed-off-by: Calum Murray <cmurray@redhat.com>
knative-prow bot pushed a commit that referenced this pull request Aug 24, 2023
Broker eventtype autocreate fixes (#7161)

* Fixed undefined typemeta on broker in eventtype autocreate



* Fixed autocreate so that only one eventtype is created when events are sent to mt channel broker



* Clean up



* Fixed unit tests



* channel only creates eventtypes if not owned by broker



---------

Signed-off-by: Calum Murray <cmurray@redhat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Auto Enabled Events only show up for InMemory channel
4 participants