-
Notifications
You must be signed in to change notification settings - Fork 597
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
Add EventPolicy reconciliation for Sequence #8106
Add EventPolicy reconciliation for Sequence #8106
Conversation
Signed-off-by: Leo Li <[email protected]>
Skipping CI for Draft Pull Request. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #8106 +/- ##
==========================================
+ Coverage 67.88% 68.06% +0.18%
==========================================
Files 368 369 +1
Lines 17565 17725 +160
==========================================
+ Hits 11924 12065 +141
- Misses 4893 4901 +8
- Partials 748 759 +11 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Leo Li <[email protected]>
pkg/reconciler/sequence/sequence.go
Outdated
if featureFlags.IsOIDCAuthentication() { | ||
// Create or update EventPolicies, and we skip the first channel as it's the input channel! | ||
for i := 1; i < len(channels); i++ { | ||
if err := r.reconcileChannelEventPolicy(ctx, s, channels[i], subs[i-1]); err != nil { | ||
return err | ||
} | ||
} | ||
|
||
// Handle input channel EventPolicy | ||
if err := r.reconcileInputChannelEventPolicy(ctx, s, channels[0]); err != nil { | ||
return err | ||
} |
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.
there are a few more cases to handle in the logic here, for example, when a channel is removed or added (meaning a step is removed or added) channels will change and we will need to remove event policies, what I would do is:
- list all the policies that belong to the given sequence (via
<prefix> + sequence-name
label) - based on the channels, partition the list in:
- to be removed
- to be updated
- go through the to be updated list and check if there is any update needed, if so, update the policy
- add new policies for new channels
- remove the policies in the to be removed partition
Optimize the algorithm where possible
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.
We need to add a handler here https://github.com/knative/eventing/blob/main/pkg/reconciler/sequence/controller.go to requeue a given sequence when event policies for a sequence change
SequenceChannelEventPolicyLabelPrefix + "sequence-group": flowsv1.SchemeGroupVersion.Group, | ||
SequenceChannelEventPolicyLabelPrefix + "sequence-version": flowsv1.SchemeGroupVersion.Version, | ||
SequenceChannelEventPolicyLabelPrefix + "sequence-kind": sequenceKind, | ||
SequenceChannelEventPolicyLabelPrefix + "sequence-name": sequenceName, |
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.
Are we using the kind, version or group label? I can only see the name being useful, and therefore the GVK can be removed
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.
If I understand the flow correctly, I think the GK is used when the controller is trying to watch which eventpolicy get changed.
eventing/pkg/reconciler/sequence/controller.go
Lines 69 to 77 in 9ea1d54
sequenceGK := flowsv1.SchemeGroupVersion.WithKind("Sequence").GroupKind() | |
// Enqueue the Sequence, if we have an EventPolicy which was referencing | |
// or got updated and now is referencing the Sequence | |
eventPolicyInformer.Informer().AddEventHandler(auth.EventPolicyEventHandler( | |
sequenceInformer.Informer().GetIndexer(), | |
sequenceGK, | |
impl.EnqueueKey, | |
)) |
// if channel name is empty, it means the event policy is for the output channel | ||
if channelName == "" { | ||
return kmeta.ChildName(sequenceName, "-ep") // no need to add the channel name |
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.
when is the channel name empty?
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.
When we are making the eventpolicy for the sequence.
As you can see from the test here:
https://github.com/knative/eventing/pull/8106/files#diff-42ed9804c3511a386317c39a39cea9571e16d694153edb7d79c800ae4589ffaaR2302
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.
Sorry, but I didn't get it, is empty only for testing? when is the channel name empty in the real production case?
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 see now by trying to answer your question. It is only for the testing purposes. I couldn't come up with any use case in the real production use. I will try to see what I can do and provide update in this thread.
Signed-off-by: Leo Li <[email protected]>
Signed-off-by: Leo Li <[email protected]>
Signed-off-by: Leo Li <[email protected]>
Isn't it already here? eventing/pkg/reconciler/sequence/controller.go Lines 71 to 77 in 9ea1d54
|
Signed-off-by: Leo Li <[email protected]>
@Leo6Leo I'm getting an error when installing the components and creating a sequence like this one:
|
There is an issue with the feature flag watch in the sequence reconciler feature.FromContext(ctx) returns empty FF, so the auth FF is always disabled, I'll open a PR with the fix |
The current issues I have found: 1. Even though the feature flag for OIDC has been disabled, the resources still have eventpolicies issue.For example, when describing the sequence, it will still show
When I tried to create the pingSource to send the events to event-display. This happens when OIDC is disabled.
2. Cannot get the Kind and APIVersion of the subscriptionsThe error logs show that when creating the eventpolicies,
The code that create the EventPolicies is here It seems like the value in the sub[] array doesn't have those 2 fields. Trying to figure things out. But if anyone has any insight, feel free to share it here! |
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.
Thanks for your work on this @Leo6Leo!
I left a few comments. Let me know if anything is unclear
Signed-off-by: Leo Li <[email protected]>
/meow |
In response to this:
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-sigs/prow repository. |
…cies requiring update and cleanup. Signed-off-by: Leo Li <[email protected]>
…, change to reflect.DeepEqual Signed-off-by: Leo Li <[email protected]>
Signed-off-by: Leo Li <[email protected]>
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.
Thanks a lot finishing this and checking on all the review comments 💪
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: creydr, Leo6Leo 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 |
Fixes #7983
Proposed Changes
Pre-review Checklist
Release Note
Docs