-
Notifications
You must be signed in to change notification settings - Fork 1.2k
🐛 Restmapper: Respect preferred version #3151
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
Conversation
pkg/client/apiutil/restmapper.go
Outdated
@@ -246,10 +246,18 @@ func (m *mapper) addGroupVersionResourcesToCacheAndReloadLocked(gvr map[schema.G | |||
} | |||
|
|||
if !found { | |||
groupResources.Group.Versions = append(groupResources.Group.Versions, metav1.GroupVersionForDiscovery{ | |||
doc := metav1.GroupVersionForDiscovery{ |
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.
What is doc
a short-name for?
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.
document
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.
doc := metav1.GroupVersionForDiscovery{ | |
gv := metav1.GroupVersionForDiscovery{ |
Short for GroupVersion. Just a suggestion. A short variable name makes sense here since the scope of the variable is short. Curious to know what doc/document has to do with this. 🤔
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.
LGTM
I've tested this fix in Flux and the issue with preferred version is gone. Thanks @alvaroaleman 🥇
@stefanprodan: changing LGTM is restricted to collaborators In response to this:
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-sigs/prow repository. |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: alvaroaleman, stefanprodan 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 |
Kind: "Driver", | ||
}) | ||
g.Expect(err).NotTo(gmg.HaveOccurred()) | ||
g.Expect(mapping.GroupVersionKind.Version).To(gmg.Equal("v2")) |
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.
Q: Just curious. What makes v2 the preferred version in this test?
Does the apiserver have some logic that prefers v2 over v1?
(maybe worth adding a godoc)
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.
Added a comment
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.
Just a minor nit question/comment from me. Otherwise LGTM! Thanks a lot for looking into this!
pkg/client/apiutil/restmapper.go
Outdated
@@ -246,10 +246,18 @@ func (m *mapper) addGroupVersionResourcesToCacheAndReloadLocked(gvr map[schema.G | |||
} | |||
|
|||
if !found { | |||
groupResources.Group.Versions = append(groupResources.Group.Versions, metav1.GroupVersionForDiscovery{ | |||
doc := metav1.GroupVersionForDiscovery{ |
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.
doc := metav1.GroupVersionForDiscovery{ | |
gv := metav1.GroupVersionForDiscovery{ |
Short for GroupVersion. Just a suggestion. A short variable name makes sense here since the scope of the variable is short. Curious to know what doc/document has to do with this. 🤔
When requesting a resource without version through methods such as `RESTMapping`, the mapper would previously return a random version rather than the preferred one, this change fixes that.
2dad16f
to
d724f7f
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.
/lgtm
LGTM label has been added. Git tree hash: ea6e2e638195caece1d1772f211f8ffc66713be6
|
@alvaroaleman: new pull request created: #3159 In response to this:
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-sigs/prow repository. |
/lgtm |
When requesting a resource without version through methods such as
RESTMapping
, the mapper would previously return a random version rather than the preferred one, this change fixes that.Fixes #3133
/cherrypick release-0.20