Skip to content

Commit 20bdbcd

Browse files
authored
fix: increase gRPC route match limit (#3601)
1 parent 2b0b9ce commit 20bdbcd

File tree

4 files changed

+64
-4
lines changed

4 files changed

+64
-4
lines changed

apis/v1/grpcroute_types.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ type GRPCRouteRule struct {
210210
// the above criteria.
211211
//
212212
// +optional
213-
// +kubebuilder:validation:MaxItems=8
213+
// +kubebuilder:validation:MaxItems=64
214214
Matches []GRPCRouteMatch `json:"matches,omitempty"`
215215

216216
// Filters define the filters that are applied to requests that match

config/crd/experimental/gateway.networking.k8s.io_grpcroutes.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/standard/gateway.networking.k8s.io_grpcroutes.yaml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/test/cel/grpcroute_test.go

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,67 @@ func TestGRPCRouteRule(t *testing.T) {
282282
},
283283
},
284284
},
285-
}
285+
{
286+
name: "too many matches and rules",
287+
wantErrors: []string{"total number of matches across all rules in a route must be less than 128"},
288+
rules: func() []gatewayv1.GRPCRouteRule {
289+
match := gatewayv1.GRPCRouteMatch{
290+
Headers: []gatewayv1.GRPCHeaderMatch{
291+
{
292+
Type: ptrTo(gatewayv1.GRPCHeaderMatchExact),
293+
Name: "version",
294+
Value: "v1",
295+
},
296+
},
297+
Method: &gatewayv1.GRPCMethodMatch{
298+
Type: ptrTo(gatewayv1.GRPCMethodMatchExact),
299+
Service: ptrTo("foo"),
300+
Method: ptrTo("bar"),
301+
},
302+
}
303+
304+
var rules []gatewayv1.GRPCRouteRule
305+
for i := 0; i < 7; i++ { // Create 7 rules
306+
rule := gatewayv1.GRPCRouteRule{}
307+
for j := 0; j < 20; j++ { // Each rule has 20 matches
308+
rule.Matches = append(rule.Matches, match)
309+
}
310+
rules = append(rules, rule)
311+
}
312+
return rules
313+
}(),
314+
},
315+
{
316+
name: "many matches and few rules",
317+
wantErrors: nil,
318+
rules: func() []gatewayv1.GRPCRouteRule {
319+
match := gatewayv1.GRPCRouteMatch{
320+
Headers: []gatewayv1.GRPCHeaderMatch{
321+
{
322+
Type: ptrTo(gatewayv1.GRPCHeaderMatchExact),
323+
Name: "version",
324+
Value: "v1",
325+
},
326+
},
327+
Method: &gatewayv1.GRPCMethodMatch{
328+
Type: ptrTo(gatewayv1.GRPCMethodMatchExact),
329+
Service: ptrTo("foo"),
330+
Method: ptrTo("bar"),
331+
},
332+
}
333+
334+
var rules []gatewayv1.GRPCRouteRule
335+
for i := 0; i < 2; i++ { // Create 2 rules
336+
rule := gatewayv1.GRPCRouteRule{}
337+
for j := 0; j < 48; j++ { // Each rule has 48 matches
338+
rule.Matches = append(rule.Matches, match)
339+
}
340+
rules = append(rules, rule)
341+
}
342+
return rules
343+
}(),
344+
}}
345+
286346
for _, tc := range tests {
287347
t.Run(tc.name, func(t *testing.T) {
288348
route := &gatewayv1.GRPCRoute{

0 commit comments

Comments
 (0)