-
Notifications
You must be signed in to change notification settings - Fork 40k
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
[GarbageCollector] let dynamic client handle non-registered ListOptions #27733
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -270,3 +270,26 @@ func (parameterCodec) DecodeParameters(parameters url.Values, from unversioned.G | |
} | ||
|
||
var defaultParameterEncoder runtime.ParameterCodec = parameterCodec{} | ||
|
||
type versionedParameterEncoderWithV1Fallback struct{} | ||
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. Registering v1.ListOptions in the Policy group will fix #27622. But for thirdparty resources, we still need this versionedParameterEncoderWithV1Fallback codec. For the record, API server always treats query parameters sent to a thirdparty resource endpoint as v1: https://github.com/kubernetes/kubernetes/blob/master/pkg/registry/thirdpartyresourcedata/codec.go#L557 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. Add as comment: "But for thirdparty resources, we still need this versionedParameterEncoderWithV1Fallback codec. For the record, currently API server always treats query parameters sent to a thirdparty resource endpoint as v1" 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. Added to the comment on |
||
|
||
func (versionedParameterEncoderWithV1Fallback) EncodeParameters(obj runtime.Object, to unversioned.GroupVersion) (url.Values, error) { | ||
ret, err := api.ParameterCodec.EncodeParameters(obj, to) | ||
if err != nil && runtime.IsNotRegisteredError(err) { | ||
// fallback to v1 | ||
return api.ParameterCodec.EncodeParameters(obj, v1.SchemeGroupVersion) | ||
} | ||
return ret, err | ||
} | ||
|
||
func (versionedParameterEncoderWithV1Fallback) DecodeParameters(parameters url.Values, from unversioned.GroupVersion, into runtime.Object) error { | ||
return errors.New("DecodeParameters not implemented on versionedParameterEncoderWithV1Fallback") | ||
} | ||
|
||
// VersionedParameterEncoderWithV1Fallback is useful for encoding query | ||
// parameters for thirdparty resources. It tries to convert object to the | ||
// specified version before converting it to query parameters, and falls back to | ||
// converting to v1 if the object is not registered in the specified version. | ||
// For the record, currently API server always treats query parameters sent to a | ||
// thirdparty resource endpoint as v1. | ||
var VersionedParameterEncoderWithV1Fallback runtime.ParameterCodec = versionedParameterEncoderWithV1Fallback{} |
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 about DeleteOptions? And ExportOptions?
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.
DeleteOptions makes sense. I'm not sure about ExportOptions. It's always treated as "v1": https://github.com/kubernetes/kubernetes/blob/master/pkg/apiserver/resthandler.go#L135, though that code might be wrong.
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 DeleteOptions but not the ExportOptions.
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.
Wow, that code is wrong.
On Tue, Jun 21, 2016 at 12:18 AM, Chao Xu 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.
ExportOptions is registered as unversioned type: https://github.com/kubernetes/kubernetes/blob/master/pkg/api/register.go#L108.
We should register it as an ordinary type. @smarterclayton Are you fine if I do that in another PR? Moving ExportOptions from unversioned/ to a api/ is an API change.
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.
We can do it in another issue - it's no less broken then (everything in an
API is versioned, even if we haven't explicitly created a second versioned
yet). Said another way, unversioned is something we haven't correctly
versioned yet (a bug).
It's not really an API change - the schema accepted is a version, so it's
really just an internal error that each group version doesn't explicitly
say what schema of export options they support.
On Tue, Jun 21, 2016 at 4:16 PM, Chao Xu 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.
Tracked in #27886