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

Allow global resync & reconcilerImpl informers to be filtered #2176

Closed
wants to merge 2 commits into from

Conversation

benmoss
Copy link
Member

@benmoss benmoss commented Jun 30, 2021

Changes

A revised implementation of #2170 and #1909, updated and now using options as per @mattmoor's ancient code review.

Also switched our reconcilers to use controller.NewImplFull since NewImpl is deprecated, and this makes setting the GlobalResyncFilterFunc easier too.

This came up again because of knative/eventing#5543, so looking to reintroduce @lberk's changes.

/cc @markusthoemmes

@google-cla
Copy link

google-cla bot commented Jun 30, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added the cla: no Indicates the PR's author has not signed the CLA. label Jun 30, 2021
@knative-prow-robot knative-prow-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jun 30, 2021
@knative-prow-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: benmoss
To complete the pull request process, please assign mattmoor after the PR has been reviewed.
You can assign the PR to them by writing /assign @mattmoor in a comment when ready.

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

options := {{.controllerControllerOptions|raw}}{
Logger: logger,
WorkQueueName: ctrTypeName,
GlobalResyncFilterFunc: func(o interface{}) bool { filterFunc(o) },
Copy link
Member Author

@benmoss benmoss Jun 30, 2021

Choose a reason for hiding this comment

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

a hacky trick here, wrapping the filterFunc in another function closes over the value so we can mutate it down below, passing filterFunc directly would pass by value: https://play.golang.org/p/lfNHOKu_yPZ

@benmoss benmoss changed the title Filter func controller informers Allow global resync & reconcilerImpl informers to be filtered Jun 30, 2021
@benmoss benmoss force-pushed the filterFunc-controller-informers branch from 8973f78 to 3ec10ea Compare June 30, 2021 16:24
@google-cla
Copy link

google-cla bot commented Jun 30, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

Users can just set the impl FilterFunc option and it will percolate down
to the controller.ControllerOptions GlobalResyncFilterFunc as well.
@benmoss benmoss force-pushed the filterFunc-controller-informers branch from 3ec10ea to f4bed1c Compare June 30, 2021 16:30
@google-cla
Copy link

google-cla bot commented Jun 30, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@codecov
Copy link

codecov bot commented Jun 30, 2021

Codecov Report

Merging #2176 (f4bed1c) into main (51cfaab) will decrease coverage by 0.04%.
The diff coverage is 55.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2176      +/-   ##
==========================================
- Coverage   66.05%   66.00%   -0.05%     
==========================================
  Files         224      224              
  Lines        9426     9437      +11     
==========================================
+ Hits         6226     6229       +3     
- Misses       2920     2928       +8     
  Partials      280      280              
Impacted Files Coverage Δ
.../injection-gen/generators/reconciler_controller.go 0.00% <0.00%> (ø)
controller/controller.go 86.71% <100.00%> (+0.15%) ⬆️
test/gcs/mock/mock.go 91.39% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 51cfaab...f4bed1c. Read the comment docs.

@@ -225,11 +234,12 @@ func NewImpl(ctx {{.contextContext|raw}}, r Interface{{if .hasClass}}, classValu
return err
}
for _, elt := range all {
// TODO: Consider letting users specify a filter in options.
Copy link
Contributor

Choose a reason for hiding this comment

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

I love it when we find a need for the TODO and then implement the TODO 😄

Copy link
Contributor

@n3wscott n3wscott left a comment

Choose a reason for hiding this comment

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

This LGTM, can I ask you to add a small note in the docs for it so someone reading the docs might realize they can use this option: https://github.com/knative/pkg/blob/main/injection/README.md

/lgtm

@knative-prow-robot knative-prow-robot added the lgtm Indicates that a PR is ready to be merged. label Jun 30, 2021
@benmoss
Copy link
Member Author

benmoss commented Jul 1, 2021

/hold

@knative-prow-robot knative-prow-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 1, 2021
@benmoss
Copy link
Member Author

benmoss commented Jul 6, 2021

Opened #2180 instead

@benmoss benmoss closed this Jul 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: no Indicates the PR's author has not signed the CLA. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm Indicates that a PR is ready to be merged. 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.

4 participants