server: allow configuration default send/recv message sizes
Signed-off-by: Stephen J Day <stephen.day@docker.com>
This commit is contained in:
parent
3e8e9d3ed7
commit
acc71293c5
@ -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
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
@ -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,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
26
defaults/defaults.go
Normal file
26
defaults/defaults.go
Normal file
@ -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
|
||||
)
|
@ -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
|
||||
|
@ -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),
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user