Skip to content

Commit cffb9cd

Browse files
owayssnutanix-Hrushikesh
authored andcommitted
fix: makes gRPC's MaxRecvMsgSize for the extension server (envoyproxy#1291)
**Description** Makes go's gRPC `MaxRecvMsgSize` configurable for the extension server, whose default value is 4MB https://pkg.go.dev/google.golang.org/grpc#MaxRecvMsgSize When the gRPC message payload from the xDS server exceeds 4MB, it is rejected by the extension server and the below errors is observed on envoy-gateway: ``` 2025-10-07T10:26:44.625Z ERROR xds runner/runner.go:245 failed to translate xds ir {"runner": "xds", "error": "rpc error: code = ResourceExhausted desc = grpc: received message larger than max (6683527 vs. 4194304)"} 2025-10-07T10:26:44.625Z ERROR watchable message/watchutil.go:86 observed an error {"runner": "xds", "error": "rpc error: code = ResourceExhausted desc = grpc: received message larger than max (6683527 vs. 4194304)"} ``` This PR makes it configurable via the command-line flag `maxRecvMsgSize` and keeps its default at 4MB. **Related Issues/PRs (if applicable)** Fixes envoyproxy#1293 Related PR to make gRPC's message sizes configurable, though that was for the external processor gRPC server: envoyproxy#1213 **Special notes for reviewers (if applicable)** Note that this applies to the xDS resource messages sent from the xDS server to the extension server. The payload of these messages increases with the size/count of the config resources. --------- Signed-off-by: Owayss Kabtoul <[email protected]> Signed-off-by: Hrushikesh Patil <[email protected]>
1 parent dba1989 commit cffb9cd

File tree

4 files changed

+20
-2
lines changed

4 files changed

+20
-2
lines changed

cmd/controller/main.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ type flags struct {
4949
extProcExtraEnvVars string
5050
// extProcMaxRecvMsgSize is the maximum message size in bytes that the gRPC server can receive.
5151
extProcMaxRecvMsgSize int
52+
// maxRecvMsgSize is the maximum message size in bytes that the gRPC extension server can receive.
53+
maxRecvMsgSize int
5254
}
5355

5456
// parsePullPolicy parses string into a k8s PullPolicy.
@@ -146,6 +148,11 @@ func parseAndValidateFlags(args []string) (flags, error) {
146148
512*1024*1024,
147149
"Maximum message size in bytes that the gRPC server can receive for extProc. Default is 512MB.",
148150
)
151+
maxRecvMsgSize := fs.Int(
152+
"maxRecvMsgSize",
153+
4*1024*1024,
154+
"Maximum message size in bytes that the gRPC extension server can receive. Default is 4MB.",
155+
)
149156

150157
if err := fs.Parse(args); err != nil {
151158
err = fmt.Errorf("failed to parse flags: %w", err)
@@ -215,6 +222,7 @@ func parseAndValidateFlags(args []string) (flags, error) {
215222
rootPrefix: *rootPrefix,
216223
extProcExtraEnvVars: *extProcExtraEnvVars,
217224
extProcMaxRecvMsgSize: *extProcMaxRecvMsgSize,
225+
maxRecvMsgSize: *maxRecvMsgSize,
218226
}, nil
219227
}
220228

@@ -271,7 +279,7 @@ func main() {
271279

272280
// Start the extension server running alongside the controller.
273281
const extProcUDSPath = "/etc/ai-gateway-extproc-uds/run.sock"
274-
s := grpc.NewServer()
282+
s := grpc.NewServer(grpc.MaxRecvMsgSize(flags.maxRecvMsgSize))
275283
extSrv := extensionserver.New(mgr.GetClient(), ctrl.Log, extProcUDSPath, false)
276284
egextension.RegisterEnvoyGatewayExtensionServer(s, extSrv)
277285
grpc_health_v1.RegisterHealthServer(s, extSrv)

cmd/controller/main_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ func Test_parseAndValidateFlags(t *testing.T) {
2929
require.Equal(t, "/certs", f.tlsCertDir)
3030
require.Equal(t, "tls.crt", f.tlsCertName)
3131
require.Equal(t, "tls.key", f.tlsKeyName)
32+
require.Equal(t, 4*1024*1024, f.maxRecvMsgSize)
3233
require.NoError(t, err)
3334
})
3435
t.Run("all flags", func(t *testing.T) {
@@ -49,6 +50,7 @@ func Test_parseAndValidateFlags(t *testing.T) {
4950
tc.dash + "port=:8080",
5051
tc.dash + "extProcExtraEnvVars=OTEL_SERVICE_NAME=test;OTEL_TRACES_EXPORTER=console",
5152
tc.dash + "spanRequestHeaderAttributes=x-session-id:session.id",
53+
tc.dash + "maxRecvMsgSize=33554432",
5254
}
5355
f, err := parseAndValidateFlags(args)
5456
require.Equal(t, "debug", f.extProcLogLevel)
@@ -59,6 +61,7 @@ func Test_parseAndValidateFlags(t *testing.T) {
5961
require.Equal(t, ":8080", f.extensionServerPort)
6062
require.Equal(t, "OTEL_SERVICE_NAME=test;OTEL_TRACES_EXPORTER=console", f.extProcExtraEnvVars)
6163
require.Equal(t, "x-session-id:session.id", f.spanRequestHeaderAttributes)
64+
require.Equal(t, 32*1024*1024, f.maxRecvMsgSize)
6265
require.NoError(t, err)
6366
})
6467
}

manifests/charts/ai-gateway-helm/templates/deployment.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ spec:
6262
- --enableLeaderElection=true
6363
{{- end }}
6464
- --rootPrefix={{ .Values.endpointConfig.rootPrefix }}
65+
{{- if ne .Values.controller.maxRecvMsgSize nil }}
66+
- --maxRecvMsgSize={{ .Values.controller.maxRecvMsgSize }}
67+
{{- end }}
6568
livenessProbe:
6669
grpc:
6770
port: 1063

manifests/charts/ai-gateway-helm/values.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,4 +155,8 @@ controller:
155155
nodeSelector: {}
156156
tolerations: []
157157
affinity: {}
158-
158+
# maxRecvMsgSize is the maximum message size in bytes that the gRPC extension server can receive
159+
# from xDS (envoy-gateway).
160+
# This value should be increased in setups where count/complexity of xDS
161+
# resources (configuration) is big. Defaults to 4MB.
162+
# maxRecvMsgSize: "4194304"

0 commit comments

Comments
 (0)