Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[release-1.28] internal/dag: 0s HTTPRoute timeout disables the timeout #6379

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions internal/dag/builder_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions internal/dag/gatewayapi_processor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down