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(): fix a bug while deleting event policies for channels #8141

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

rahulii
Copy link
Contributor

@rahulii rahulii commented Aug 8, 2024

Fixes #

Proposed Changes

  • 🐛 Delete the backingChannel Event Policy in case the channel event policy is deleted

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

Delete the backingChannel Event Policy in case the channel event policy is deleted

Docs

Copy link

knative-prow bot commented Aug 8, 2024

Skipping CI for Draft Pull Request.
If you want CI signal for your change, please convert it to an actual PR.
You can still manually trigger a test run with /test all

@knative-prow knative-prow bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 8, 2024
@knative-prow knative-prow bot requested a review from aliok August 8, 2024 13:13
Copy link

knative-prow bot commented Aug 8, 2024

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: rahulii
Once this PR has been reviewed and has the lgtm label, please assign psschwei for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found 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 requested a review from pierDipi August 8, 2024 13:13
@rahulii rahulii marked this pull request as ready for review August 8, 2024 13:13
@knative-prow knative-prow bot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 8, 2024
@knative-prow knative-prow bot requested review from aslom and matzew August 8, 2024 13:13
@knative-prow knative-prow bot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Aug 8, 2024
@rahulii
Copy link
Contributor Author

rahulii commented Aug 8, 2024

/cc: @creydr

Signed-off-by: rahulii <[email protected]>
Copy link

codecov bot commented Aug 8, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.93%. Comparing base (20a64a1) to head (cfdc012).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #8141      +/-   ##
==========================================
+ Coverage   67.89%   67.93%   +0.03%     
==========================================
  Files         368      368              
  Lines       17570    17566       -4     
==========================================
+ Hits        11929    11933       +4     
+ Misses       4893     4886       -7     
+ Partials      748      747       -1     

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

@creydr
Copy link
Member

creydr commented Aug 9, 2024

Hello @rahulii,
I am sorry for the back and forth on this. But as said in Slack, I remembered, that we set the OwnerReference in the backingChannels EventPolicy to the "parent"-channels EventPolicy:

APIVersion: parentPolicy.GetGroupVersionKind().GroupVersion().String(),
Kind: parentPolicy.GetGroupVersionKind().Kind,
Name: parentPolicy.Name,
UID: parentPolicy.UID,

So we should be fine with deleting the backing channels EP, when the channels EP gets deleted.

But as you said, we should have at least a test for it. So we could have a unit test, which tests, that the owner reference is set correctly (the deletion is a k8s internal part). WDYT about updating your PR to add a test case for this instead?

@rahulii
Copy link
Contributor Author

rahulii commented Aug 9, 2024

Hello @rahulii, I am sorry for the back and forth on this. But as said in Slack, I remembered, that we set the OwnerReference in the backingChannels EventPolicy to the "parent"-channels EventPolicy:

APIVersion: parentPolicy.GetGroupVersionKind().GroupVersion().String(),
Kind: parentPolicy.GetGroupVersionKind().Kind,
Name: parentPolicy.Name,
UID: parentPolicy.UID,

So we should be fine with deleting the backing channels EP, when the channels EP gets deleted.

But as you said, we should have at least a test for it. So we could have a unit test, which tests, that the owner reference is set correctly (the deletion is a k8s internal part). WDYT about updating your PR to add a test case for this instead?

that makes sense, will update the PR!
will have to add E2E tests in the future for testing the deletions

@rahulii
Copy link
Contributor Author

rahulii commented Aug 9, 2024

Hello @rahulii, I am sorry for the back and forth on this. But as said in Slack, I remembered, that we set the OwnerReference in the backingChannels EventPolicy to the "parent"-channels EventPolicy:

APIVersion: parentPolicy.GetGroupVersionKind().GroupVersion().String(),
Kind: parentPolicy.GetGroupVersionKind().Kind,
Name: parentPolicy.Name,
UID: parentPolicy.UID,

So we should be fine with deleting the backing channels EP, when the channels EP gets deleted.

But as you said, we should have at least a test for it. So we could have a unit test, which tests, that the owner reference is set correctly (the deletion is a k8s internal part). WDYT about updating your PR to add a test case for this instead?

@creydr so the current changes I made, should I revoke them ? should we keep the code as it was before this PR ? 🤔

@creydr
Copy link
Member

creydr commented Aug 9, 2024

I would only add a unit test in this PR

@rahulii
Copy link
Contributor Author

rahulii commented Aug 9, 2024

@creydr if you see a unit test case just above this - https://github.com/knative/eventing/blob/main/pkg/reconciler/channel/channel_test.go#L574
it checks for owner references , so thic test case would be exactly same I believe.
Do you think we should add the exact same TC ?

@creydr
Copy link
Member

creydr commented Aug 9, 2024

ok. Then I think we're fine here and can close this PR

@rahulii
Copy link
Contributor Author

rahulii commented Aug 9, 2024

ok. Then I think we're fine here and can close this PR

@creydr I was just thinking, if k8s will automatically clean the policies, what the point of keeping https://github.com/knative/eventing/pull/8141/files#diff-118d54e11363ce17cd0de2c082c234f0dcd47f4d1078f58d1d6b0866a091886bL141-L162 ?
Aren't these un-necessary cycles?

And even though if we are keeping those (let's say a double check), I believe it still has a bug which can be solved.
WDYT?

@matzew
Copy link
Member

matzew commented Oct 16, 2024

ok. Then I think we're fine here and can close this PR

are we done here?

@creydr
Copy link
Member

creydr commented Oct 16, 2024

And even though if we are keeping those (let's say a double check), I believe it still has a bug which can be solved.

@rahulii I guess the check doesn't hurt ATM. I only don't get, where the bug is 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

3 participants