-
Notifications
You must be signed in to change notification settings - Fork 14
UPSTREAM: <carry>: do not set the generation for cached object #106
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
UPSTREAM: <carry>: do not set the generation for cached object #106
Conversation
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 don't believe you need to get/set the map. You should be able to delete directly. https://go.dev/play/p/r7Wr8PbmwN9. Hopefully meta.Accessor doesn't change that?
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.
ah, right, recently I have worked with an unstructured object that gave me a copy, here indeed we get a pointer.
db55afd to
a267022
Compare
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.
idiomatic: _, found := accessor.GetAnnotations()[genericapirequest.AnnotationKey]; found
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.
Funny, I told Joaquim to just do if annotations[key] != "" the other day. I'd call this one personal preference maybe.
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.
if the language was more strict we wouldn't have to discuss at least 3 different ways of reading a value from a map :)
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.
don't think this is correct (have seen the old thread). GetAnnotations() returns a map[string]string. In unstructured, it is map[string]interface{}. Hence, there must be a deepcopy with type cast happening.
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.
To avoid the deepcopy use the *NoCopy unstructured helpers.
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.
brought back the previous version, I don't think we need to use NoCopy. Using GetAnnotaions/SetAnnotations is always correct.
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.
serverResource uses unstructuredCreator, that means requests to that EP will operate on unstructured data
kubernetes/staging/src/k8s.io/apiextensions-apiserver/pkg/apiserver/customresource_handler.go
Line 871 in 3ddc03b
| creator := unstructuredCreator{} |
a267022 to
f64b618
Compare
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 think that comparing to an empty string is more readable but I can change to _, found := accessor.GetAnnotations()[genericapirequest.AnnotationKey]; !found
f64b618 to
eada9e1
Compare
|
/lgtm |
This PR allows:
Essentially, the generation field for cached objects won't be managed by the generic/extensions API server.
part of kcp-dev/kcp#342