diff --git a/README.md b/README.md index 16c07c278..2d59b8151 100644 --- a/README.md +++ b/README.md @@ -178,6 +178,10 @@ OPTIONS: server listener. Set to 0 to disable. (default: 9092) [$BAZEL_REMOTE_GRPC_PORT] + --grpc_max_recv_msg_size value The maximum message size in bytes the gRPC + server can receive. (default: 4194304) + [$BAZEL_REMOTE_GRPC_MAX_RECV_MSG_SIZE] + --profile_address value Address specification for a http server to listen on for profiling, formatted either as [host]:port for TCP or unix://path.sock for Unix domain sockets. Off by default, but can also be @@ -444,6 +448,9 @@ http_address: 0.0.0.0:8080 # as described above): #grpc_address: 0.0.0.0:9092 +# Increase the gRPC server maximum receive message size +#grpc_max_recv_msg_size: 26214400 + # If profile_address (or the deprecated profile_port and/or profile_host) # is specified, then serve /debug/pprof/* URLs here (unix sockets are also # supported as described above): @@ -575,7 +582,7 @@ http_address: 0.0.0.0:8080 # auth_method: environment_credential # # auth_method: default - + # If set to a valid port number, then serve /debug/pprof/* URLs here: #profile_port: 7070 # IP address to use, if profiling is enabled: @@ -635,7 +642,7 @@ See [examples/docker-compose.yml](examples/docker-compose.yml) for an example co configuration. * Don't name your deployment `bazel-remote`! - + Kubernetes sets some environment variables based on this name, which conflict with the `BAZEL_REMOTE_*` environment variables that bazel-remote tries to parse. diff --git a/config/config.go b/config/config.go index 51655d00d..1801531fb 100644 --- a/config/config.go +++ b/config/config.go @@ -114,6 +114,7 @@ type Config struct { LogTimezone string `yaml:"log_timezone"` MaxBlobSize int64 `yaml:"max_blob_size"` MaxProxyBlobSize int64 `yaml:"max_proxy_blob_size"` + GrpcMaxRecvMsgSize int `yaml:"grpc_max_recv_msg_size"` // Fields that are created by combinations of the flags above. ProxyBackend cache.Proxy @@ -169,7 +170,9 @@ func newFromArgs(dir string, maxSize int, storageMode string, zstdImplementation accessLogLevel string, logTimezone string, maxBlobSize int64, - maxProxyBlobSize int64) (*Config, error) { + maxProxyBlobSize int64, + grpcMaxRecvMsgSize int, +) (*Config, error) { c := Config{ HTTPAddress: httpAddress, @@ -205,6 +208,7 @@ func newFromArgs(dir string, maxSize int, storageMode string, zstdImplementation LogTimezone: logTimezone, MaxBlobSize: maxBlobSize, MaxProxyBlobSize: maxProxyBlobSize, + GrpcMaxRecvMsgSize: grpcMaxRecvMsgSize, } err := validateConfig(&c) @@ -245,6 +249,7 @@ func newFromYaml(data []byte) (*Config, error) { MetricsDurationBuckets: defaultDurationBuckets, AccessLogLevel: "all", LogTimezone: "UTC", + GrpcMaxRecvMsgSize: 1024 * 1024 * 4, }, } @@ -623,5 +628,6 @@ func get(ctx *cli.Context) (*Config, error) { ctx.String("log_timezone"), ctx.Int64("max_blob_size"), ctx.Int64("max_proxy_blob_size"), + ctx.Int("grpc_max_recv_msg_size"), ) } diff --git a/config/config_test.go b/config/config_test.go index 429e87081..ca2e6a4ee 100644 --- a/config/config_test.go +++ b/config/config_test.go @@ -29,6 +29,7 @@ http_read_timeout: 5s http_write_timeout: 10s access_log_level: none log_timezone: local +grpc_max_recv_msg_size: 26214400 ` config, err := newFromYaml([]byte(yaml)) @@ -60,6 +61,7 @@ log_timezone: local MetricsDurationBuckets: []float64{.5, 1, 2.5, 5, 10, 20, 40, 80, 160, 320}, AccessLogLevel: "none", LogTimezone: "local", + GrpcMaxRecvMsgSize: 26214400, } if !reflect.DeepEqual(config, expectedConfig) { @@ -341,7 +343,7 @@ func TestStorageModes(t *testing.T) { }{{ yaml: `host: localhost port: 1234 -dir: /foo/bar +dir: /foo/bar max_size: 20 `, expected: "zstd", @@ -349,7 +351,7 @@ max_size: 20 { yaml: `host: localhost port: 1234 -dir: /foo/bar +dir: /foo/bar max_size: 20 storage_mode: zstd `, @@ -358,7 +360,7 @@ storage_mode: zstd { yaml: `host: localhost port: 1234 -dir: /foo/bar +dir: /foo/bar max_size: 20 storage_mode: uncompressed `, @@ -367,7 +369,7 @@ storage_mode: uncompressed { yaml: `host: localhost port: 1234 -dir: /foo/bar +dir: /foo/bar max_size: 20 storage_mode: gzip `, diff --git a/main.go b/main.go index 9472701b8..26c4f9fe7 100644 --- a/main.go +++ b/main.go @@ -393,6 +393,8 @@ func startGrpcServer(c *config.Config, grpcServer **grpc.Server, opts = append(opts, grpc.ChainStreamInterceptor(streamInterceptors...)) opts = append(opts, grpc.ChainUnaryInterceptor(unaryInterceptors...)) + log.Println("Setting gRPC Max Receive Message Size to:", c.GrpcMaxRecvMsgSize) + opts = append(opts, grpc.MaxRecvMsgSize(c.GrpcMaxRecvMsgSize)) validateAC := !c.DisableGRPCACDepsCheck validateStatus := "disabled" diff --git a/utils/flags/flags.go b/utils/flags/flags.go index 10e3b0d40..fdb730b1a 100644 --- a/utils/flags/flags.go +++ b/utils/flags/flags.go @@ -175,6 +175,13 @@ func GetCliFlags() []cli.Flag { DefaultText: strconv.FormatInt(math.MaxInt64, 10), EnvVars: []string{"BAZEL_REMOTE_MAX_BLOB_SIZE"}, }, + &cli.IntFlag{ + Name: "grpc_max_recv_msg_size", + Value: 1024 * 1024 * 4, + Usage: "The maximum message size in bytes the gRPC server can receive.", + DefaultText: strconv.FormatInt(1024*1024*4, 10), + EnvVars: []string{"BAZEL_REMOTE_GRPC_MAX_RECV_MSG_SIZE"}, + }, &cli.Int64Flag{ Name: "max_proxy_blob_size", Value: math.MaxInt64,