-
Notifications
You must be signed in to change notification settings - Fork 38.6k
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
fix group mapping and encoding order #20846
Merged
k8s-github-robot
merged 1 commit into
kubernetes:master
from
deads2k:fix-groupmapping-order
Feb 15, 2016
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,12 +57,20 @@ func NewCodec( | |
if encodeVersion != nil { | ||
internal.encodeVersion = make(map[string]unversioned.GroupVersion) | ||
for _, v := range encodeVersion { | ||
// first one for a group wins. This is consistent with best to worst order throughout the codebase | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This part is fine with me |
||
if _, ok := internal.encodeVersion[v.Group]; ok { | ||
continue | ||
} | ||
internal.encodeVersion[v.Group] = v | ||
} | ||
} | ||
if decodeVersion != nil { | ||
internal.decodeVersion = make(map[string]unversioned.GroupVersion) | ||
for _, v := range decodeVersion { | ||
// first one for a group wins. This is consistent with best to worst order throughout the codebase | ||
if _, ok := internal.decodeVersion[v.Group]; ok { | ||
continue | ||
} | ||
internal.decodeVersion[v.Group] = v | ||
} | ||
} | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Map traversal are not stable, is this expect to be?
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.
No. Godoc specifies:
Groups are randomly ordered, but versions within groups are priority order from best to worst
. Random ordering on groups works, but we need correct ordering on versions within those groups.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.
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.
When choosing how to encode with a legacy encoder, the first matching group is used. This is a natural method for getting all the GroupVersions and since the group will be traversed eventually, the group ordering doesn't matter. The version ordering within that group is critical.
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 on the version ordering. I'm just trying to understand why enabled
versions is random. It's fine for this issue, but I don't know that I
consider randomness correct in this context.
On Wed, Feb 10, 2016 at 8:31 AM, David Eads notifications@github.com
wrote:
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 not sure that I know what order I'd like this to have. I know that I don't like alphabetical, because everyone will name theirs
aaaa
. Given package loading ordering which isn't obvious to me, I'm not sure that I like enablement order.I think I want group ordering to be suggested by discover endpoints and strictly ordered client-side if desired.
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.
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.
Hrm, ok, so this is a behavior change for ordering, I think after discussion we said this might break rest mapper because it relies on
extensions/v1beta1.pods
to come afterv1.pods
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 discussion was related to a different pull where I explicitly called out the change in the description: #20829 This has never had an ordering guarantee before.