Header to explicit raw-stream implementation being used#39812
Header to explicit raw-stream implementation being used#39812thaJeztah merged 1 commit intomoby:masterfrom
Conversation
|
Thanks! Is the same change needed for other endpoints that have a similar "raw" stream? ( We should probably document the additions to the headers in the Swagger file; at least a note in the version history; https://github.com/moby/moby/blob/53430f5/docs/api/version-history.md#v141-api-changes Possibly in the section describing the stream format https://github.com/moby/moby/blob/9c94e82/api/swagger.yaml#L5864-L5896 And possibly |
|
|
a153d14 to
d7c8a6f
Compare
|
the commit description needs to be updated, as this is no longer doc-only change |
|
by |
thaJeztah
left a comment
There was a problem hiding this comment.
LGTM
agreed that the first line of the commit message may be a bit misleading, so would be nice to have it include that it's changing the header
|
Do we need an API version switch on this? Otherwise, very nice. I think this would also make it so the CLI doesn't need to do an inspect (IIRC) to check for TTY |
We may not need to, given that the content-type itself doesn't change, we're only adding parameters (which are optional, and can be ignored unless a client is looking for it specifically). So unless a client takes the raw
https://play.golang.org/p/my367gBiJ5w package main
import (
"fmt"
"mime"
)
func main() {
mediaType, params, _ := mime.ParseMediaType("application/vnd.docker.raw-stream; stream=raw; something=else; lang=en_US")
fmt.Println("mediatype:", mediaType)
fmt.Printf("params: %v\n", params)
}We could add more documentation around it (if the |
|
updated commit message and PR description |
cpuguy83
left a comment
There was a problem hiding this comment.
Going back and forth if we should switch on API version here.
I think we need to just because we aren't going to send a non-multiplexed stream to an older client but we may do that in the future (actually I would really like to see this).
api/swagger.yaml
Outdated
There was a problem hiding this comment.
may claim, if it does not then assume multiplexed.
8f194c8 to
1f016e1
Compare
3340c31 to
4560517
Compare
|
Not sure how to address buid failure |
|
afaict most of the recent commits on master just failed on CI. |
|
@cpuguy83 updated: new |
35a19e4 to
95ca82f
Compare
cpuguy83
left a comment
There was a problem hiding this comment.
No requests for change just a point of discussion (sorry!)
errdefs/helpers.go
Outdated
|
|
||
| type errNotAcceptable struct{ error } | ||
|
|
||
| func (errNotAcceptable) NotAcceptable() {} |
There was a problem hiding this comment.
I wonder if this is necessary over using InvalidParameter?
How will a client respond to the two things differently?
I guess in this case it would strictly be a client misconfiguration as opposed to a user providing invalid/incorrect data.
Reading up on the usage of the error code from https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/406 it also seems the recommendation is to go ahead and send an OK response anyway and leave it to the client to understand that the media type is not what they asked for.
Thinking and reading maybe my suggestion to use accept headers was not useful after all.
- An older client will continue to get old media types
- A new client that did not make changes for the new API (or an un-versioned client) is technically incorrect but likely won't be checking mediatype anyway and will use old behavior (calling
/containers/<id>/json) - A "proper" new client will look at the mediatype returned
I guess my original thought around using accept headers was to help ensure compatibility for clients in camp 2.
I was also thinking that we would return the type of stream that was requested in the accept header in all cases, but that's not actually the case and wouldn't really work anyway (at least not well).
So... is camp 2 worth it?
|
We discussed this PR in the maintainers meeting. We had some discussion about whether
So even though the use-cases are currently limited; it was considered good to do it "right", and to already use this status code. There were some other points discussed, but the consensus was that we're ok with the current approach; I asked some maintainers to have a look at the implementation, and to accept/merge this PR unless there are really major issues (minor issues / improvements / cleanups for follow-ups if needed). |
|
We're going back and forth on this topic, trying to find a good "HTTP-friendly" way to manage this, but actually we are not negociating content, there's a single stream type we can return, and this PR is all about documenting this. Could have ben a custom header added to the HTTP response. I'm a favor to give up with client's |
|
Continuing to ignore the client's |
This is the option I selected on my last push, reverting content negociation and attempts to rely on |
|
Can we have a test for this? There may be some API related tests already that can check the response header. |
6cdeb33 to
ce52815
Compare
api/types/client.go
Outdated
| type HijackedResponse struct { | ||
| Conn net.Conn | ||
| Reader *bufio.Reader | ||
| Multiplexed *bool |
There was a problem hiding this comment.
Maybe the content type string here?
There was a problem hiding this comment.
That's an option indeed. But then I'll suggest to define func (HijackedResponse) IsMultiplexed() bool
as the consumer don't really care about content type, just want to know how to access payload streams :)
There was a problem hiding this comment.
That's fine for me (or a function in the package that defines the content-type values)... and/or a generic ConsumeStdStream.
I like to avoid such bool fields because invariably more than the bool is needed, and then we are dealing with pointers everywhere.
46449f7 to
cc1292c
Compare
fix moby#35761 Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
closes #35761
- What I did
Document the actual raw-stream mechanism being used (raw or multiplexed)
- How I did it
Added a Content-Type parameter following RFC 7231
- How to verify it
run a container with our without tty option and check Content-type header on attach
- Description for the changelog
attach API declares raw-stream format in use within Content-type header
- A picture of a cute animal (not mandatory but encouraged)
