-
Notifications
You must be signed in to change notification settings - Fork 578
Add StreamTimeout field for gRPC streaming calls #6508
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
base: main
Are you sure you want to change the base?
Conversation
Add StreamTimeout field to HTTPTimeout struct in BackendTrafficPolicy to enable configuration of timeouts specifically for gRPC streaming requests. Key changes: 1. Add StreamTimeout field to api/v1alpha1/timeout_types.go 2. Add StreamTimeout field to internal/ir/xds.go HTTPTimeout 3. Update buildClusterSettingsTimeout to process StreamTimeout 4. Update XDS translation to use StreamTimeout for gRPC routes (IsHTTP2) 5. Add getEffectiveTimeout function to prioritize StreamTimeout for gRPC routes When StreamTimeout is set to 0s, timeouts are disabled for streaming requests. This resolves the 15-second timeout limitation for gRPC streaming calls. Signed-off-by: Shivam Mittal <[email protected]>
Update CRDs, Helm charts, and other generated files to include the new StreamTimeout field in HTTPTimeout structs. Signed-off-by: Shivam Mittal <[email protected]>
|
|
||
| // StreamTimeout is the timeout for streaming requests. This timeout does not apply to non-streaming requests. | ||
| // When set to "0s", the timeout is disabled for streaming requests, allowing them to run indefinitely. | ||
| // This is particularly useful for gRPC streaming calls. | ||
| // Default: inherited from RequestTimeout. | ||
| // | ||
| // +optional | ||
| StreamTimeout *gwapiv1.Duration `json:"streamTimeout,omitempty"` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RequestTimeout doesn't currently get evaluated for GRPCRoutes at all. What do you think about merging the two and treating RequestTimeout like this for GRPCRoutes?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think keeping RequestTimeout and StreamTimeout separate is clearer for users, since unary and streaming gRPC calls often need different timeouts. Merging them could cause confusion or accidental misconfiguration. Explicit fields make the API more intuitive and safer for production use.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the docs I'm a bit confused as to where the different timeouts intersect. It seems like the overall Route Timeout (which for HTTPRoutes get implemented via RequestTimeout) takes precedence over the Stream Timeout value but that might be irrelevant of your change here.
https://www.envoyproxy.io/docs/envoy/latest/faq/configuration/timeouts#route-timeouts
The route idle_timeout allows overriding of the HTTP connection manager stream_idle_timeout and does the same thing.
I agree they should stay separate, thanks!
|
this doesnt look right imo we should set and if we are introducing a new |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6508 +/- ##
==========================================
- Coverage 71.05% 71.01% -0.04%
==========================================
Files 225 225
Lines 38992 39015 +23
==========================================
+ Hits 27705 27707 +2
- Misses 9684 9704 +20
- Partials 1603 1604 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
I tried to implement this, but the grpc_timeout_header_max field is not available in the current version of the Envoy Go API (go-control-plane). I updated to the latest version, but the field is still missing from the generated RouteAction struct. |
|
|
|
/retest |
| func getEffectiveTimeout(httpRoute *ir.HTTPRoute) *metav1.Duration { | ||
| // For gRPC routes (IsHTTP2), check if streaming timeout is configured | ||
| if httpRoute.IsHTTP2 && | ||
| httpRoute.Traffic != nil && | ||
| httpRoute.Traffic.Timeout != nil && | ||
| httpRoute.Traffic.Timeout.HTTP != nil && | ||
| httpRoute.Traffic.Timeout.HTTP.StreamTimeout != nil { | ||
| // StreamTimeout takes precedence for gRPC/HTTP2 routes | ||
| return httpRoute.Traffic.Timeout.HTTP.StreamTimeout | ||
| } | ||
|
|
||
| // Fall back to regular request timeout for non-gRPC routes or when no StreamTimeout is configured | ||
| return getEffectiveRequestTimeout(httpRoute) | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a testdata example for this? I'm fairly confident that getEffectiveRequestTimeout already doesn't run for GRPCRoutes so am curious if this is being skipped too.
Edit: Confirmed that BTP requestTimeout gets skipped for GRPCRoutes currently. Not expecting you to fix requestTimeout in this PR but I think your new field here will get skipped as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was so confidently incorrect... ignore me but would still like to include testdata
Signed-off-by: shiavm006 <[email protected]>
| } | ||
| } | ||
|
|
||
| func TestGetEffectiveTimeout(t *testing.T) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great and fixes code coverage CI but please also add to internal/xds/translator/testdata
|
/retest |
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions! |
|
This pull request has been automatically marked as stale because it has not had activity in the last 30 days. Please feel free to give a status update now, ping for review, when it's ready. Thank you for your contributions! |
This PR implements support for configuring timeouts specifically for gRPC streaming requests in
BackendTrafficPolicy, resolving the issue where gRPC streaming connections were limited to a hardcoded 15-second timeout.Issue being fixed #5446
Problem
EnvoyPatchPolicyworkaroundsSolution
StreamTimeoutfield inHTTPTimeoutstructStreamTimeoutif set, falls back toRequestTimeoutRequestTimeout(no change)"0s"to disable timeout for infinite streamingTesting Done
make test)make lint)make generate)make manifests)