Natively support gRPC on the docker socket#50744
Conversation
| client.WithSessionDialer(func(ctx context.Context, proto string, meta map[string][]string) (net.Conn, error) { | ||
| return c.DialHijack(ctx, "/session", proto, meta) | ||
| }), | ||
| client.WithContextDialer(func(ctx context.Context, _ string) (net.Conn, error) { | ||
| return c.DialHijack(ctx, "/grpc", "h2c", nil) | ||
| }), |
There was a problem hiding this comment.
Do we need to keep the /grpc and /session endpoints? IIUC removing these means that any existing version of buildx or the CLI will break?
There was a problem hiding this comment.
Oh, ignore me; this is client-side 🙈
I guess clients should still try both to stay compatible, right?
There was a problem hiding this comment.
docker/buildx#3369 handles both, I don't know if any other clients are using and if we can just safely deprecate those endpoints since using them requires a very delicate dance.
There was a problem hiding this comment.
Basically any version of buildx that currently exists; i.e., we can't remove the old endpoints, as they're part of the API
There was a problem hiding this comment.
Could we use HTTP 301 Moved Permanently for legacy clients to switch to the updated endpoint?
There was a problem hiding this comment.
FWIW; this is only the test, not the endpoint being removed (🙈); so probably fine, but we can consider officially deprecating the old endpoints
|
This failure looks potentially related; Details |
|
Looks like this requires updating the From #49836 (comment), I saw that @corhere originally suggested some approach through
Also;
|
|
I pushed a commit to update the Go version in |
|
100% using golang.org/x/net like I suggested would not require bumping the go version. And I would still prefer that approach over open-coding it again since we got it wrong open-coding it the first time around. |
1.23 is deprecated, the min version will get bumped as soon as we vendor in a project which bumps it (containerd 2.2 or anything that has a transitive Kubernetes dep)
Can you explain this one further. I usually think the preferred solution is using the standard library as the Go maintainers have encouraged not using those lower level libraries. "This package is low-level and intended to be used directly by very few people", we aren't doing anything that special here. Not sure what "over open-coding it again" refers to or how it relates to the existing hijack approach, which I think we all agree isn't great. |
0f2fc4a to
8756712
Compare
8756712 to
c8eb19a
Compare
Use the GRPC server when requests are for the grpc content type. Signed-off-by: Derek McGowan <[email protected]>
c8eb19a to
d210449
Compare
|
I’ve rebased this PR and removed the When a TLS listener receives a connection, it returns an error if the handshake can’t be completed. As a result, h2c won’t be used for TLS listeners, but it will be used for non-TLS TCP connections and the UNIX socket. In the previous iteration, gRPC was disabled when running the dev container with the API exposed over TCP. This is now resolved. |
| }) | ||
| httpServer.Handler = apiServer.CreateMux(ctx, routers...) | ||
| gs := newGRPCServer(ctx) | ||
| b.backend.RegisterGRPC(gs) |
There was a problem hiding this comment.
Note: This will implicitly expose the containerd content store via buildkit:
It's read-only so that's good, but we should make that explicitly registered by the Moby and not implicitly by Buildkit.
Adds support for directly serving the gRPC server on the Docker socket. The requests can be easily detected from the content-type and use of HTTP 2. Explicitly adds the HTTP 2 protocol when using tcp+tls or unencrypted HTTP 2 when using a unix socket.
Only registers the buildkit service, which will allow deprecating the hijacking
/sessionand/grpcendpoints. In the future, we can register more services using containerd style plugins.- Human readable description for the release notes