-
Notifications
You must be signed in to change notification settings - Fork 19
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
✨ Introduce structured keys in pkg/cache #70
base: main
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
533e455
to
63bd172
Compare
63bd172
to
f0b0334
Compare
/cc @vincepri |
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 is something we had some informal conversations about a couple years ago, the comments in the Kubernetes codebase seem to suggest that a) there was some thought to making this structured in the past and b) there were also concerns about allocations. It might be good to see if e.g. David Eads or Jordan Liggitt have in their memory some conversations on this topic. Certainly OK to add this as an opt-in option for controller authors, but if there are no real concerns with the approach it might be nice to get it to be the default, too.
// structured keys for API objects which implement meta.Interface. | ||
// This is the structured alternative to MetaClusterNamespaceKeyFunc; | ||
// putting such an object reference in a queue means that no parsing errors are possible downstream. | ||
func ObjMetaClusterNamespaceKey(obj interface{}) (Key, error) { |
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.
nit: the convention is to call this a KeyFunc
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.
Yeah, I never understood why the names of these functions have to end in "Func" while all the other functions do not require that. The more common use of the suffix "Func" is in the name of a type, not a function.
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 agree! I only point it out since it might make it clearer for consumers that are used to that convention.
I am not sure I follow the concern about allocations. I am assuming that both boxing a I think this PR is written in such a way that it does introduce an "opt in". |
I'm not entirely clear on the allocation concerns but I think it was moreso the allocation for the |
The upstream version of this is kubernetes/kubernetes#116869 |
Closing & re-opening the PR to trigger the new CI setup. Please do not be alarmed :) |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: 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 |
@MikeSpreitzer: The following test failed, say
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. I understand the commands that are listed here. |
Summary
Did you know that a controller's workqueue contains
any
value, not necessarily astring
? This PR adds a structured alternative to the common encoded string, relieving queue consumers from the complexity of coping with parsing errors. It is also a useful datatype in many other places.Related issue(s)
Fixes #