-
Notifications
You must be signed in to change notification settings - Fork 39.7k
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
support removal of event handlers from SharedIndexInformers #111122
Conversation
/sig api-machinery |
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.
This looks pretty good to me!
I was struggling to give meaningful feedback, mostly because I was trying to understand the diff between this and where mandelsoft left off but it’s a little hard because a lot has changed between then and now.
My understanding is that the main changes are:
- Using the opaque interface as the registration handle
- Turning the shared processor’s listeners slice into a map of listener to a bool of if they’re syncing (making the syncing listeners slice redundant).
Let me know if I’m missing anything else, but overall looks good, I’ll leave it for others to review.
/assign @lavalamp please take a look when you can |
/retest |
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'm a little concerned about the locking -- often for stuff like this I like to have a test that repeatedly and randomly adds and removes thingies to look for locking errors. Given the tests you added, it's probably not mandatory if you're super confident, but I think that there's a reasonable chance adding this could e.g. expose an existing such bug?
staging/src/k8s.io/client-go/tools/cache/shared_informer_test.go
Outdated
Show resolved
Hide resolved
staging/src/k8s.io/client-go/tools/cache/shared_informer_test.go
Outdated
Show resolved
Hide resolved
To be able to implement controllers that are dynamically deciding on which resources to watch, it is required to get rid of dedicated watches and event handlers again. This requires the possibility to remove event handlers from SharedIndexInformers again. Stopping an informer is not sufficient, because there might be multiple controllers in a controller manager that independently decide which resources to watch. Unfortunately the ResourceEventHandler interface encourages to use value objects for handlers (like the ResourceEventHandlerFuncs struct, that uses value receivers to implement the interface). Go does not support comparison of function pointers and therefore the comparison of such structs is not possible, also. To be able to remove all kinds of handlers and to solve the problem of multi-registrations of handlers a registration handle is introduced. It is returned when adding a handler and can later be used to remove the registration again. This handle directly stores the created listener to simplify the deletion.
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, I've looked at the code, will take a look at the tests next.
Looks good to me, I'll let someone more knowledgable of this area tag for me. Thanks! |
/assign @deads2k |
staging/src/k8s.io/client-go/tools/cache/shared_informer_test.go
Outdated
Show resolved
Hide resolved
only one minor comment, probably ready to go otherwise? |
/approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alexzielenski, lavalamp 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 |
/retest |
/lgtm Thanks! |
What type of PR is this?
/kind feature
What this PR does / why we need it:
Text from original PR:
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Continuation of #98657 after work there no longer took place.
Does this PR introduce a user-facing change?
Additional documentation e.g., KEPs (Kubernetes Enhancement Proposals), usage docs, etc.:
/cc @FillZpp
/cc @kevindelgado