From cdbfae1d3eb658d7ee467006972004927ff78158 Mon Sep 17 00:00:00 2001 From: Sebastiaan van Stijn Date: Fri, 26 Jul 2024 11:06:39 +0200 Subject: [PATCH] api/server/router/grpc: NewRouter: set correct MaxRecvMsgSize, MaxSendMsgSize [buildkit@29b4b1a537][1] applied changes to `buildkitd` to set the correct defaults, which should be 16MB, but used the library defaults. Without that change, builds using large Dockerfiles would fail with a `ResourceExhausted` error; => [internal] load build definition from Dockerfile => => transferring dockerfile: 896.44kB ERROR: failed to receive status: rpc error: code = ResourceExhausted desc = grpc: received message larger than max (44865299 vs. 16777216) However those changes were applied to the `buildkitd` code, which is the daemon when running BuildKit standalone (or in a container through the `container` driver). When running a build with the BuildKit builder compiled into the Docker Engine, that code is not used, so the BuildKit changes did not fix the issue. This patch applies the same changes as were made in [buildkit@29b4b1a537][1] to the gRPC endpoint provided by the dockerd daemon. [1]: https://github.com/moby/buildkit/commit/29b4b1a53795c5f2e4469a2ead7891ba0d704bca Signed-off-by: Sebastiaan van Stijn --- api/server/router/grpc/grpc.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/api/server/router/grpc/grpc.go b/api/server/router/grpc/grpc.go index 7f26f06b7dae6..a22bc1d6daae3 100644 --- a/api/server/router/grpc/grpc.go +++ b/api/server/router/grpc/grpc.go @@ -9,6 +9,7 @@ import ( "os" "strings" + "github.com/containerd/containerd/defaults" "github.com/containerd/log" "github.com/docker/docker/api/server/router" "github.com/moby/buildkit/util/grpcerrors" @@ -32,6 +33,8 @@ func NewRouter(backends ...Backend) router.Router { grpc.StatsHandler(tracing.ServerStatsHandler(otelgrpc.WithTracerProvider(otel.GetTracerProvider()))), grpc.ChainUnaryInterceptor(unaryInterceptor, grpcerrors.UnaryServerInterceptor), grpc.StreamInterceptor(grpcerrors.StreamServerInterceptor), + grpc.MaxRecvMsgSize(defaults.DefaultMaxRecvMsgSize), + grpc.MaxSendMsgSize(defaults.DefaultMaxSendMsgSize), } r := &grpcRouter{