-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
📖 Explain what may happen when using OnlyMetadata and Get on the concrete type instead of PartialMetadataObject #1747
Conversation
|
Welcome @maelvls! |
Hi @maelvls. Thanks for your PR. I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the 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. |
fcd8310
to
167c960
Compare
f51ece6
to
d50964d
Compare
d50964d
to
1bc3f4a
Compare
@maelvls is this still a work in progress? As far as I can tell, this looks like a great clarification and something we could go ahead and merge. |
Thanks, I think it is ready to go! |
pkg/builder/options.go
Outdated
// pod := &v1.Pod{} // ❌ | ||
// mgr.GetClient().Get(ctx, nsAndName, pod) // ❌ | ||
// | ||
// pod := &metav1.PartialObjectMetadata{} // ✅ |
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.
Doesn't this need typemeta set?
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.
That's a very good point, controller-runtime would have a hard time figuring out which type we are referring to with just &metav1.PartialObjectMetadata{}
😅
I fixed this in 3318359.
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.
thank you!
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, maelvls 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 |
In #1660, we found that it is too easy for users to duplicate cache projections, for example by creating a watch with
OnlyMetadata
, which creates a metadata cache, and then using the concrete type to get the watched object, which automatically creates a cache of the concrete projection.Duplicating the cached projections is probably never what the user wanted to do, and leads to:
At first, I wanted to follow the suggestion in #1660 (comment):
I then realized that I don't really know how to make this change.
Can I suggest starting with a quick warning that people would see when looking at
OnlyMetadata
? In this PR, I added the warning.To sum up my goal in this PR, I wish to document the following:
The three following Get calls will create three different caches:
Caches are not synchronized, meaning that you may end up with data races when using two different cache projections.
Using OnlyMetadata option should not be used with the concrete nor the unstructured clients.