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

xds: parse timeout from RDS responses #7257

Merged
merged 5 commits into from Jul 31, 2020

Conversation

voidzcy
Copy link
Contributor

@voidzcy voidzcy commented Jul 28, 2020

A small part of implementing per-method timeout configuration.

return StructOrError.fromStruct(new RouteAction(cluster, weightedClusters));
long timeoutNano = TimeUnit.SECONDS.toNanos(15L); // default 15s
if (proto.hasMaxGrpcTimeout()) {
timeoutNano = Durations.toNanos(proto.getMaxGrpcTimeout());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -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
Copy link
Member

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

Copy link
Member

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)

Copy link
Contributor Author

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.

Copy link
Member

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"

Copy link
Member

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?

Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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?

@voidzcy voidzcy merged commit 14af76c into grpc:master Jul 31, 2020
voidzcy added a commit to voidzcy/grpc-java that referenced this pull request Aug 11, 2020
dfawley pushed a commit to dfawley/grpc-java that referenced this pull request Jan 15, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 10, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants