diff --git a/client.go b/client.go index 77a54f02d..ede55e7ef 100644 --- a/client.go +++ b/client.go @@ -38,6 +38,7 @@ import ( versionservice "github.com/containerd/containerd/api/services/version/v1" "github.com/containerd/containerd/containers" "github.com/containerd/containerd/content" + "github.com/containerd/containerd/defaults" "github.com/containerd/containerd/dialer" "github.com/containerd/containerd/errdefs" "github.com/containerd/containerd/events" @@ -90,6 +91,10 @@ func New(address string, opts ...ClientOpt) (*Client, error) { grpc.FailOnNonTempDialError(true), grpc.WithBackoffMaxDelay(3 * time.Second), grpc.WithDialer(dialer.Dialer), + + // TODO(stevvooe): We may need to allow configuration of this on the client. + grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(defaults.DefaultMaxRecvMsgSize)), + grpc.WithDefaultCallOptions(grpc.MaxCallSendMsgSize(defaults.DefaultMaxSendMsgSize)), } if len(copts.dialOptions) > 0 { gopts = copts.dialOptions diff --git a/cmd/containerd/command/config_linux.go b/cmd/containerd/command/config_linux.go index bb083c0e0..2b522989d 100644 --- a/cmd/containerd/command/config_linux.go +++ b/cmd/containerd/command/config_linux.go @@ -26,7 +26,9 @@ func defaultConfig() *server.Config { Root: defaults.DefaultRootDir, State: defaults.DefaultStateDir, GRPC: server.GRPCConfig{ - Address: defaults.DefaultAddress, + Address: defaults.DefaultAddress, + MaxRecvMsgSize: defaults.DefaultMaxRecvMsgSize, + MaxSendMsgSize: defaults.DefaultMaxSendMsgSize, }, } } diff --git a/cmd/containerd/command/config_windows.go b/cmd/containerd/command/config_windows.go index bb083c0e0..2b522989d 100644 --- a/cmd/containerd/command/config_windows.go +++ b/cmd/containerd/command/config_windows.go @@ -26,7 +26,9 @@ func defaultConfig() *server.Config { Root: defaults.DefaultRootDir, State: defaults.DefaultStateDir, GRPC: server.GRPCConfig{ - Address: defaults.DefaultAddress, + Address: defaults.DefaultAddress, + MaxRecvMsgSize: defaults.DefaultMaxRecvMsgSize, + MaxSendMsgSize: defaults.DefaultMaxSendMsgSize, }, } } diff --git a/defaults/defaults.go b/defaults/defaults.go new file mode 100644 index 000000000..7040f5b85 --- /dev/null +++ b/defaults/defaults.go @@ -0,0 +1,26 @@ +/* + Copyright The containerd Authors. + + Licensed under the Apache License, Version 2.0 (the "License"); + you may not use this file except in compliance with the License. + You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + See the License for the specific language governing permissions and + limitations under the License. +*/ + +package defaults + +const ( + // DefaultMaxRecvMsgSize defines the default maximum message size for + // receiving protobufs passed over the GRPC API. + DefaultMaxRecvMsgSize = 16 << 20 + // DefaultMaxSendMsgSize defines the default maximum message size for + // sending protobufs passed over the GRPC API. + DefaultMaxSendMsgSize = 16 << 20 +) diff --git a/server/config.go b/server/config.go index 67d1f4bcb..41d08b43c 100644 --- a/server/config.go +++ b/server/config.go @@ -49,9 +49,11 @@ type Config struct { // GRPCConfig provides GRPC configuration for the socket type GRPCConfig struct { - Address string `toml:"address"` - UID int `toml:"uid"` - GID int `toml:"gid"` + Address string `toml:"address"` + UID int `toml:"uid"` + GID int `toml:"gid"` + MaxRecvMsgSize int `toml:"max_recv_message_size"` + MaxSendMsgSize int `toml:"max_send_message_size"` } // Debug provides debug configuration diff --git a/server/server.go b/server/server.go index f5b24f636..59c74d08b 100644 --- a/server/server.go +++ b/server/server.go @@ -67,6 +67,8 @@ func New(ctx context.Context, config *Config) (*Server, error) { return nil, err } rpc := grpc.NewServer( + grpc.MaxRecvMsgSize(config.GRPC.MaxRecvMsgSize), + grpc.MaxSendMsgSize(config.GRPC.MaxSendMsgSize), grpc.UnaryInterceptor(grpc_prometheus.UnaryServerInterceptor), grpc.StreamInterceptor(grpc_prometheus.StreamServerInterceptor), )