-
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
apiserver: clarify watcher fanout deepcopy and self-link code #105700
Closed
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
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 |
---|---|---|
|
@@ -31,6 +31,8 @@ import ( | |
"k8s.io/apimachinery/pkg/runtime/schema" | ||
"k8s.io/apiserver/pkg/endpoints/handlers/negotiation" | ||
"k8s.io/apiserver/pkg/endpoints/handlers/responsewriters" | ||
"k8s.io/apiserver/pkg/features" | ||
utilfeature "k8s.io/apiserver/pkg/util/feature" | ||
utiltrace "k8s.io/utils/trace" | ||
) | ||
|
||
|
@@ -59,8 +61,18 @@ func doTransformObject(ctx context.Context, obj runtime.Object, opts interface{} | |
if _, ok := obj.(*metav1.Status); ok { | ||
return obj, nil | ||
} | ||
if err := setObjectSelfLink(ctx, obj, req, scope.Namer); err != nil { | ||
return nil, err | ||
|
||
if !utilfeature.DefaultFeatureGate.Enabled(features.RemoveSelfLink) { | ||
if err := setObjectSelfLink(ctx, obj, req, scope.Namer); err != nil { | ||
return nil, err | ||
} | ||
} | ||
|
||
// Ensure that for empty lists we don't return <nil> items. | ||
if meta.IsListType(obj) && meta.LenList(obj) == 0 { | ||
if err := meta.SetList(obj, []runtime.Object{}); err != nil { | ||
return nil, err | ||
} | ||
} | ||
Comment on lines
+71
to
76
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. off the top of my head, I can't think of a reason it would matter, but since SetList was conditionally done at the top of |
||
|
||
switch target := mediaType.Convert; { | ||
|
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
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.
Actually - I'm fairly sure you can just remove "setObjectSelfLink" from here completely.
before (currently in line 241) you are calling transformResponseObject, which underneaths is calling transformObject which is setting selflink.
So I think it's not needed at all.
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.
only exception is
metav1.Status
which skips transformObject for whatever reason. Do we care?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.
Hmm - I can't see how this can matter if we call it only in patch and not in created/update/get/...
If it matters - I think we should set it in other operations too, right?
So I think that we should set it elsewhere too or get rid from here for consistency...
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'd rather not spend a lot of time trying to fix existing inconsistencies in self-link-adding, since that is disabled by default and is planned to be removed. Just honoring the feature gate here is easier to reason about.
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.
OK - I would like to propose it for 1.24 (we moved to Beta in 1.16, so I think we're either ready to do that now or will never be). I'm going to start a conversation for it on slack.
But with that - I agree this is probably a moot discussion.