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
xds: parse timeout from RDS responses #7257
xds: parse timeout from RDS responses #7257
Conversation
return StructOrError.fromStruct(new RouteAction(cluster, weightedClusters)); | ||
long timeoutNano = TimeUnit.SECONDS.toNanos(15L); // default 15s | ||
if (proto.hasMaxGrpcTimeout()) { | ||
timeoutNano = Durations.toNanos(proto.getMaxGrpcTimeout()); |
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.
If configured as 0, the maximum allowed timeout for gRPC requests is infinity.
https://github.com/envoyproxy/envoy/blob/c694e470dbc9a1dd24b296d117330f0e5becb2c9/api/envoy/api/v2/route/route_components.proto#L964
@@ -1067,18 +1069,30 @@ public String toString() { | |||
|
|||
/** See corresponding Envoy proto message {@link io.envoyproxy.envoy.api.v2.route.RouteAction}. */ | |||
static final class RouteAction { | |||
// Specifies the upstream timeout for the route, which spans between the point at which | |||
// the entire downstream request (i.e., end-of-stream) has been processed and when the |
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.
The "downstream end-of-stream has been processed" in envoy API doc is about the stream from client to the envoy proxy, which more or less corresponds to onComplete()
of client's request StreamObserver in proxyless case (Because the local xds plugin itself is the "envoy proxy".). I think it shouldn't be stated as "end-of-stream has been processed" for the proxyless case, in which the stream connects to the backend directly. cc @dfawley @ejona86
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 also just noticed that by the description of this envoy API doc, in bidi-streaming or client-streaming case, the timeout
may not be converted to grpc deadline. (Although max_grpc_timeout
can always be converted to grpc deadline)
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.
Deleted the comment if you don't like it (although I don't think there is any problem stating in that way as the description is from the perspective of a Route, "downstream" still makes senses from an implementation's perspective).
Envoy's API doc also mentions that a value of 0 for timeout
will disable the route's timeout. Added that case 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.
Deleted the comment if you don't like it (although I don't think there is any problem stating in that way as the description is from the perspective of a Route, "downstream" still makes senses from an implementation's perspective).
The timeout
java field is a combination of timeout
envoy api field and max_grpc_timeout
envoy api field (The latter, if specified, overrides the former). And I noticed that the two envoy api fields measure different time span for grpc requests, especially for client-streaming case. The latter definitely does not measure the span from "downstream EOS"
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 didn't notice this detail before (timeout
starts counting after the client sends its end-stream). This behavior might be difficult to implement -- at least we can't do it in Go for unary RPCs without some changes in the channel.
@markdroth do you think we'll need to match Envoy behavior here, or could we treat it as a known difference and call it out in the design?
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 don't think it's really necessary to mimic Envoy's behavior in this regard. I think it's fine for us to just use this to control our existing timeout semantics, just as if timeout were set via the service config.
We should call this out in the gRFC, though.
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.
A preexisting management server may set the HTTP timeout
for only 500ms, with grpc_max_timeout
unset. This works perfectly for long client streaming with envoy proxy. But it will fail all client streaming requests from a proxyless grpc client.
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.
How about we don't support HTTP timeout
for client/bidi streaming, only max_grpc_timeout
is supported for them?
A small part of implementing per-method timeout configuration.