-
Notifications
You must be signed in to change notification settings - Fork 38.8k
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
[client-go] Renegotiate Streaming Content-Type #62175
[client-go] Renegotiate Streaming Content-Type #62175
Conversation
cc @kubernetes/sig-api-machinery-bugs @kubernetes/sig-api-machinery-pr-reviews |
if err != nil { | ||
return nil, err | ||
} | ||
normalDecoder, streamingSerializer, framer, err = r.serializers.RenegotiatedStreaming(mediaType, params) |
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.
this assumes RenegotiatedStreaming is non-nil?
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.
the code seemed to assume StreamingSerializer was non-nil before. I'll add a check in to be safe.
@@ -200,6 +201,14 @@ func createSerializers(config ContentConfig) (*Serializers, error) { | |||
if info.StreamSerializer != nil { | |||
s.StreamingSerializer = info.StreamSerializer.Serializer | |||
s.Framer = info.StreamSerializer.Framer | |||
s.RenegotiatedStreaming = func(contentType string, params map[string]string) (runtime.Decoder, runtime.Serializer, runtime.Framer, error) { |
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.
definitely needs tests to cover positive and negative cases around 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.
yep, will do. Wanted to make sure there wasn't something I missed with the approach.
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.
pushed some basic tests, can do more if needed (will probably write a few more on monday anyway)
REST clients in client-go have two content type fields -- the "accepted" content types, and the default content type. When we set up serializers and such, we set up default decoders, etc for the default content type, and set up a "renegotiation function" to renegotiate in case the server sends some other content type. However, in the case of streaming, we don't do renegotiation properly -- we assume whatever the server sent is compatible with our default stream framing/decoding. This is fine an dandy when it actually is compatible, and is generally fine an dandy when using the JSON content type as the default, because most things support JSON. However, if you set your default up to, say, protobuf, and then try to use that REST config to construct a REST client for talking to the custom resources API server, you're going to have a bad time, since it doesn't support protobuf, only JSON. This in turn causes weird behavior like watches starting succesfully, but never actuall firing any watch events. To fix this, this commit introduces a new renegotiation function for streaming serialization and framing, and checks to see if it needs to be used.
2ca9e67
to
bd2f112
Compare
cc @yliaog |
@DirectXMan12: PR needs rebase. 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. |
Issues go stale after 90d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Stale issues rot after 30d of inactivity. If this issue is safe to close now please do so with Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
Rotten issues close after 30d of inactivity. Send feedback to sig-testing, kubernetes/test-infra and/or fejta. |
@fejta-bot: Closing this PR. 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/test-infra repository. |
@DirectXMan12: The following tests failed, say
Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR. 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. I understand the commands that are listed here. |
Yes, symptoms described here is what I saw in #67803 (review). Client created there worked just fine with JSON, only watch events were sent by API server as protobuf and the client failed to parse them. My informer thus did not get any events. |
I'll try and rebase this soonish |
This e2e test reproduces kubernetes#62175 and will be expanded to check for other negotiation related errors against real servers.
This e2e test reproduces kubernetes#62175 and will be expanded to check for other negotiation related errors against real servers.
This e2e test reproduces kubernetes#62175 and will be expanded to check for other negotiation related errors against real servers.
This e2e test reproduces kubernetes#62175 and will be expanded to check for other negotiation related errors against real servers.
/close in favor of #84692 |
@liggitt: Closed this PR. 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/test-infra repository. |
This e2e test reproduces kubernetes#62175 and will be expanded to check for other negotiation related errors against real servers.
REST clients in client-go have two content type fields -- the "accepted"
content types, and the default content type. When we set up
serializers and such, we set up default decoders, etc for the default
content type, and set up a "renegotiation function" to renegotiate in
case the server sends some other content type.
However, in the case of streaming, we don't do renegotiation properly --
we assume whatever the server sent is compatible with our default stream
framing/decoding.
This is fine an dandy when it actually is compatible, and is generally
fine an dandy when using the JSON content type as the default, because
most things support JSON. However, if you set your default up to, say,
protobuf, and then try to use that REST config to construct a REST
client for talking to the custom resources API server, you're going to
have a bad time, since it doesn't support protobuf, only JSON.
This in turn causes weird behavior like watches starting succesfully,
but never actuall firing any watch events.
To fix this, this commit introduces a new renegotiation function for
streaming serialization and framing, and checks to see if it needs to be
used.
Release note: