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

Use filtered informer to watch OIDC service accounts #7527

Merged
merged 41 commits into from
Jan 30, 2024

Conversation

yijie-04
Copy link
Contributor

@yijie-04 yijie-04 commented Jan 2, 2024

Fixes #7341

Proposed Changes

  • 🎁 labelled the OIDC service accounts and used a filtered serviceaccount informer based on the label

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


Docs

Copy link

linux-foundation-easycla bot commented Jan 2, 2024

CLA Signed

The committers listed above are authorized under a signed CLA.

Copy link

knative-prow bot commented Jan 2, 2024

Welcome @yijie-04! It looks like this is your first PR to knative/eventing 🎉

@knative-prow knative-prow bot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 2, 2024
Copy link

knative-prow bot commented Jan 2, 2024

Hi @yijie-04. 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 /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

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.

@Leo6Leo
Copy link
Member

Leo6Leo commented Jan 3, 2024

@yijie-04 Thanks for the PR!
As this is your very first PR in the LFX(linux fundation) community, please make sure you complete the EasyCLA so that you are authorized to contribute to Knative.

Here is the link on what is EasyCLA and how to complete it.

@Leo6Leo
Copy link
Member

Leo6Leo commented Jan 5, 2024

@yijie-04 Replying your DM here so others can also benefit from this! Usually when you complete the EasyCLA authorization, check in the GitHub action should turn green immediately. If that doesn't change, there is probably something wrong. Please make sure the github account you used for this PR and the one you used with CLA are the same. Let me know if that helps!

Copy link
Member

@Leo6Leo Leo6Leo left a comment

Choose a reason for hiding this comment

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

/ok-to-test

Thanks @yijie-04 for the PR! Just left few comments. PTAL whenever you have time!

unfiltered service account informers for OIDC service accounts are currently used in multiple places. Most of the fixed Support auto generation of XYZ identity service account and expose in AuthStatus issues in https://github.com/orgs/knative/projects/66/views/4 will probably use it

As @creydr mentioned, there are multiple places are using the unfiltered service account informers. Could you try to update them to use filtered informers too?

Great work Yijie, and please let me know if you need any help!

pkg/reconciler/broker/trigger/controller.go Outdated Show resolved Hide resolved
pkg/reconciler/broker/trigger/controller.go Outdated Show resolved Hide resolved
@knative-prow knative-prow bot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 5, 2024
@yijie-04 yijie-04 changed the title Use filtered informer to watch OIDC service accounts [WIP] Use filtered informer to watch OIDC service accounts Jan 6, 2024
@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 Jan 6, 2024
@Leo6Leo
Copy link
Member

Leo6Leo commented Jan 8, 2024

@yijie-04 Hello Yijie! Are there anything that blocking you? Any help I can provide you with?

@yijie-04
Copy link
Contributor Author

yijie-04 commented Jan 10, 2024

@Leo6Leo Thank you for checking in! It took me a bit of time to debug the unit-tests and it turned out to be simpler than I thought! I'm looking at the other tests right now and it seems that I'm receiving the timeout waiting for pods to come up error. Do you have any suggestions on how I can approach this?

@Leo6Leo
Copy link
Member

Leo6Leo commented Jan 10, 2024

@yijie-04 Hey Yijie, no problem, that's happened to me a lot too! Replying to your question, you can always click into the details for the failed prow test, and click on open Raw build-log.txt to gain the full error logs. For example, this is the real reason why your test is failing. Link

And as prow suggested, you will need to rebase the PR as some newly merged changes on the main branch is conflicting with your current changes.

See the screenshot on how to find the
image
"Raw build-log.txt`

lmk if you have any other questions!

@knative-prow-robot knative-prow-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 10, 2024
@yijie-04 yijie-04 changed the title [WIP] Use filtered informer to watch OIDC service accounts Use filtered informer to watch OIDC service accounts Jan 26, 2024
@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 Jan 26, 2024
@Leo6Leo
Copy link
Member

Leo6Leo commented Jan 26, 2024

@yijie-04 There are still some goimports issue in your PR.

To fix the formatting issue, here are some practical commands you should be aware of:

  1. go fmt ./... to format all the files in the project
  2. goimports -w ./... will run go imports for all the files

When you are running these commands, you should be careful that we don't want to format the files in the vendor folder and the third_party folder.

And there is a convenient tool that I have made to combine the gofmt and goimport to a single command. Take a look at the source code to understand how that work and Just make sure run this script every time before you commit!

@Cali0707
Copy link
Member

/retest-required
Looks like the failure is a flaky test @yijie-04 - don't worry about it

@yijie-04
Copy link
Contributor Author

@Cali0707 @Leo6Leo Got it, thank you! I just finished formatting the files and I'll wait to see the test results. I do have some questions as I was formatting the code:

  • I was running the commands for formatting earlier but nothing got changed (I also didn't receive any errors). However, after I had minikube running, the files were properly formatted. Why would formatting Go code require setting up a Kubernetes environment on my system?
  • I'm also curious about the difference between the two commands, go fmt and goimports. It seems that all the files were formatted after running go fmt ./..., so what's the use of goimports?

Thanks a lot!

@Leo6Leo
Copy link
Member

Leo6Leo commented Jan 29, 2024

Hey @yijie-04, Great to hear that you've managed to format the files!! Let's address your questions:

  1. Formatting Go Code and Kubernetes Environment:
    It's unusual that the Go code formatting seemed to require Minikube running. Typically, go fmt and goimports are independent of Kubernetes or any specific runtime environment. Their functionality is only focused on code formatting and organization.

  2. Difference Between go fmt and goimports:
    The key difference lies in their functionality scope. go fmt is a more basic tool, part of the Go toolchain, focusing on making the code's formatting style standardized (for examples like indentations and spacing). On the other hand, goimports does everything go fmt does, but it also manages import lines - it adds missing import packages and removes unused ones. link This additional feature of goimports makes it particularly useful since Go is quite strict about import usage.

In short, while go fmt ensures your code is stylistically consistent, goimports also helps in maintaining clean and effective import statements.

Hope this clarifies your doubts! Don't hesitate to reach out if you have more questions!

@Cali0707
Copy link
Member

/retest-required

@yijie-04
Copy link
Contributor Author

@Leo6Leo That makes a lot more sense, thank you so much for the clarification!

Copy link
Member

@Cali0707 Cali0707 left a comment

Choose a reason for hiding this comment

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

Hi @yijie-04 just a few nits and then this should be good to merge. Specifically, it looks like in the unit test files you are still having the label values as an empty string instead of "enabled". It doesn't seem to be breaking anything currently, but for the sake of keeping the unit tests close to the actual code I think we should probably fix those before we merge this PR. This may break a couple unit tests which are expecting the label value to be "", but you should be able to just go through those and switch it to "enabled"

pkg/reconciler/apiserversource/apiserversource_test.go Outdated Show resolved Hide resolved
pkg/reconciler/apiserversource/apiserversource_test.go Outdated Show resolved Hide resolved
Copy link
Member

@Cali0707 Cali0707 left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve

Thanks @yijie-04 for all of your work on this! 🎉🎉

@knative-prow knative-prow bot added the lgtm Indicates that a PR is ready to be merged. label Jan 30, 2024
Copy link

knative-prow bot commented Jan 30, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: Cali0707, yijie-04

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 Jan 30, 2024
@knative-prow knative-prow bot merged commit ff52881 into knative:main Jan 30, 2024
36 of 39 checks passed
@Leo6Leo
Copy link
Member

Leo6Leo commented Jan 30, 2024

@yijie-04 Congrats on the merging! Thanks for the effort you put into this and hope to see more contributions from you in Knative community!

creydr pushed a commit to creydr/knative-eventing that referenced this pull request Apr 24, 2024
* controller.go changed

* knative#7320 WIP

* WIP: Testing filtered informer (knative#7341)

* unit test passed

* Revert "Merge remote-tracking branch 'otherfork/main' into main"

This reverts commit 94cd51b, reversing
changes made to 0bf2982.

* Removed comments

* Changed to filtered informer for Subscription identity service account

* Changed to filtered informer for Sequence service accounts

* Changed to filtered informer for Parallel identity service accounts

* Changed to filtered informer for APIServerSource identity service account

* fixed unit tests

* added label selector for mtchannel_broker

* added filtered informer for sinkbinding identity service accounts

* added OIDC label selector in webhook

* added filtered informer for containersource  service accounts

* added filtered informer for pingsource service accounts

* added OIDC label selector in apiserver ctx

* added OIDC label selector in broker/filter

* added OIDC label selector in broker/ingress

* added OIDC label selector in in_memory/channel_dispatcher

* added OIDC label selector in mtping

* fixed unit test issues for pingsource

* fixed unit test for container source

* formatted files

* updated service account informer in apiserversource

* updated service account informers in other places

* small typo fix

* added actual value for OIDC label

* added a valid value for OIDClabelkey

* changed references of OIDCLabelKey

* fixed import path problem

* changed OIDCLabelSelector in all main.go files

* changed instances of OIDCLabelSelector in controller and controller test files

* deleted OIDC related labels from register.go

* fixed formatting issues

* Added value for OIDCLabelKey

---------

Co-authored-by: Scott <scottprotoss@gmail.com>
openshift-merge-bot bot pushed a commit to openshift-knative/eventing that referenced this pull request Apr 24, 2024
…y, if SA references a trigger for correct broker class (#592)

* Use filtered informer to watch OIDC service accounts (knative#7527)

* controller.go changed

* knative#7320 WIP

* WIP: Testing filtered informer (knative#7341)

* unit test passed

* Revert "Merge remote-tracking branch 'otherfork/main' into main"

This reverts commit 94cd51b, reversing
changes made to 0bf2982.

* Removed comments

* Changed to filtered informer for Subscription identity service account

* Changed to filtered informer for Sequence service accounts

* Changed to filtered informer for Parallel identity service accounts

* Changed to filtered informer for APIServerSource identity service account

* fixed unit tests

* added label selector for mtchannel_broker

* added filtered informer for sinkbinding identity service accounts

* added OIDC label selector in webhook

* added filtered informer for containersource  service accounts

* added filtered informer for pingsource service accounts

* added OIDC label selector in apiserver ctx

* added OIDC label selector in broker/filter

* added OIDC label selector in broker/ingress

* added OIDC label selector in in_memory/channel_dispatcher

* added OIDC label selector in mtping

* fixed unit test issues for pingsource

* fixed unit test for container source

* formatted files

* updated service account informer in apiserversource

* updated service account informers in other places

* small typo fix

* added actual value for OIDC label

* added a valid value for OIDClabelkey

* changed references of OIDCLabelKey

* fixed import path problem

* changed OIDCLabelSelector in all main.go files

* changed instances of OIDCLabelSelector in controller and controller test files

* deleted OIDC related labels from register.go

* fixed formatting issues

* Added value for OIDCLabelKey

---------

Co-authored-by: Scott <scottprotoss@gmail.com>

* Reconcile trigger on OIDC service account changes only, if SA references a trigger for correct broker class (knative#7849)

* Reconcile trigger on OIDC service account changes only, if SA references a trigger for correct broker class

* Run goimports and gofmt

* Remove deprecated use of pointer.Bool(v) and switch to prt.Bool(v)

---------

Co-authored-by: Yijie Wang <147119743+yijie-04@users.noreply.github.com>
Co-authored-by: Scott <scottprotoss@gmail.com>
Cali0707 added a commit to Cali0707/eventing that referenced this pull request Jul 4, 2024
knative-prow bot pushed a commit that referenced this pull request Jul 9, 2024
* Watch only our own OIDC-related secrets (#8070)

Filter OIDC secrets

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>

* ./hack/update-deps.sh

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

* fix: serviceaccountInformer -> oidcServiceaccountInformer

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

* fix: add oidc label selector to main contexts (partial cherry pick of #7527)

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

* fix: don't use filtered sa informer when sa is not labelled

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

---------

Signed-off-by: Pierangelo Di Pilato <pierdipi@redhat.com>
Signed-off-by: Calum Murray <cmurray@redhat.com>
Co-authored-by: Pierangelo Di Pilato <pierdipi@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. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Use filtered informer to watch OIDC service accounts
6 participants