diff --git a/internal/dag/builder_test.go b/internal/dag/builder_test.go index 78941f7bd7e..83e5e61d3e5 100644 --- a/internal/dag/builder_test.go +++ b/internal/dag/builder_test.go @@ -3393,6 +3393,30 @@ func TestDAGInsertGatewayAPI(t *testing.T) { }, ), }, + "HTTPRoute rule with 0s (disabled) request timeout": { + gatewayclass: validClass, + gateway: gatewayHTTPAllNamespaces, + objs: []any{ + kuardService, + makeHTTPRouteWithTimeouts("0s", ""), + }, + want: listeners( + &Listener{ + Name: "http-80", + VirtualHosts: virtualhosts( + virtualhost("test.projectcontour.io", + &Route{ + PathMatchCondition: prefixString("/"), + Clusters: clustersWeight(service(kuardService)), + TimeoutPolicy: RouteTimeoutPolicy{ + ResponseTimeout: timeout.DisabledSetting(), + }, + }, + ), + ), + }, + ), + }, "HTTPRoute rule with request and backendRequest timeout": { gatewayclass: validClass, gateway: gatewayHTTPAllNamespaces, diff --git a/internal/dag/gatewayapi_processor.go b/internal/dag/gatewayapi_processor.go index 526a87beb72..4da6c15d549 100644 --- a/internal/dag/gatewayapi_processor.go +++ b/internal/dag/gatewayapi_processor.go @@ -1139,6 +1139,11 @@ func parseHTTPRouteTimeouts(httpRouteTimeouts *gatewayapi_v1.HTTPRouteTimeouts) return nil, fmt.Errorf("invalid HTTPRoute.Spec.Rules.Timeouts.Request: %v", err) } + // For Gateway API a zero-valued timeout means disable the timeout. + if requestTimeout.Duration() == 0 { + requestTimeout = timeout.DisabledSetting() + } + return &RouteTimeoutPolicy{ ResponseTimeout: requestTimeout, }, nil