You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
allow preserving the route cache in the JSON-gRPC transcoder filter #2847
Description:
The JSON-gRPC transcoder currently clears the route cache (here), causing routes to be recalculated based on the outgoing request headers (e.g. the transformed :path header, etc.).
This is useful if the user has defined routes that match the outgoing request. If the user has not defined these outgoing routes, requests will be terminated with a 404 (for no cluster match for URL '/<service>/<method>').
It is currently not possible to use this filter to transcode requests that match the incoming request headers (i.e., without telling Envoy to recalculate the routes for transcoded requests).
What I'd like to request is an extra config option for this filter to allow the filter to transcode a request without recalculating the route. A simple bool would be enough, something like bool skip_recalculating_route.
What is the use case of not defining a route for outgoing request? Can you provide a concrete example, better with a sample envoy config?
I feel the configuration would make users confused, even you can skip the route cache being reset by the JSON-gRPC transcoder, other filters can trigger it easily. We might need a better approach to solve your issue.
What is the use case of not defining a route for outgoing request? Can you provide a concrete example, better with a sample envoy config?
Using the following gRPC method as an example:
// Returns a list of all shelves in the bookstore.
rpc ListShelves(google.protobuf.Empty) returns (ListShelvesResponse) {
option(google.api.http)= {
get: "/shelves"
};
}
The incoming request must already match GET /shelves in order to get routed to ListShelves. Why should the author of Envoy's config also need to be aware of the route on the upstream, /bookstore.Bookstore/ListShelves? Envoy already knows this because it has access to my descriptors.pb.
The workflow I'd like to achieve could conceivably be like this:
The incoming request matches == GET /shelves
The control plane for Envoy creates a route for GET /shelves indicating the upstream gRPC service the request maps to
Request comes in, is transcoded, and is properly routed to the upstream without any party having to know the corresponding route the gRPC service is expecting
This allows me to have one source of truth about what the upstream mapping is: the proto descriptor file. Neither the client, nor the control plane / user configuring Envoy need to introspect the proto descriptor to understand this.
Before the proposed change to Envoy, my route config looks like this:
This is especially useful for a self-service configuration design.
Sorry if this example is too verbose or misses the point; the tldr is that i'd like a self-service client who is as decoupled as possible from the upstream gRPC service. Since the client already needs to know the incoming request path, I feel that should be enough to achieve the transcoding.
The incoming request must already match GET /shelves in order to get routed to ListShelves. Why should the author of Envoy's config also need to be aware of the route on the upstream, /bookstore.Bookstore/ListShelves? Envoy already knows this because it has access to my descriptors.pb.
The author of Envoy's config is alreay aware of the route on the upstream, since they needs to specify services, and they can let the descriptors.pb to decide what incoming request looks like. For example they can just route prefix /bookstore.Bookstore/ to route the whole gRPC service to a cluster.
In most cases, users use both native gRPC and JSON-gRPC transcoding at same time, in that case, route based on outgoing request are same for same service/method, i.e. /bookstore.Bookstore/ListShelves.
I partly agree this is a valid use case if the author of Envoy's config only cares about incoming request and don't use native-gRPC at all.
However I would still disagree with your change #2848, since current behavior that routes are pre-calculate before HTTP filter chain and transcoder clears the cache is not Envoy standard and not documented somewhere, it is just a implementation detail. This behavior might be changed in future Envoy version, this happened before.
Looks like you want the author of Envoy's config to be focused on incoming request, there are other filters that clears route caches as well (like Lua filter, it does many things). So rather than add a flag to change the implementation behavior of gRPC-JSON transcoder as a "fix", I think adding a flag like route_based_on_incoming_request to [HTTP route config] is more appropriate for this case.
Hmm. Would need to think about this more. I suppose we could add some type of option that locks the ingress route, but then filters would basically not work and I think that would be super confusing. i guess my gut feeling is to make this an option on a per-filter basis if it makes sense to do so.
I'm OK to doing per-filter basis. I thought it just confuses more in cases that some filter combinations would result random routing result. IMO having the option that locks the ingress route might confuses filter devs more, but confuses users less.
I would also vote for per-filter, since I think we are going to provide surprising behavior to users in any case if we break filters that can't handle route locking. This is the least surprising path IMHO.
Activity
lizan commentedon Mar 20, 2018
What is the use case of not defining a route for outgoing request? Can you provide a concrete example, better with a sample envoy config?
I feel the configuration would make users confused, even you can skip the route cache being reset by the JSON-gRPC transcoder, other filters can trigger it easily. We might need a better approach to solve your issue.
ilackarms commentedon Mar 20, 2018
Using the following gRPC method as an example:
The incoming request must already match
GET /shelvesin order to get routed toListShelves. Why should the author of Envoy's config also need to be aware of the route on the upstream,/bookstore.Bookstore/ListShelves? Envoy already knows this because it has access to mydescriptors.pb.The workflow I'd like to achieve could conceivably be like this:
GET /shelvesGET /shelvesindicating the upstream gRPC service the request maps toThis allows me to have one source of truth about what the upstream mapping is: the proto descriptor file. Neither the client, nor the control plane / user configuring Envoy need to introspect the proto descriptor to understand this.
Before the proposed change to Envoy, my route config looks like this:
and my request needs to look like
What I want instead is the following:
And my incoming request still points to
/shelvesThis is especially useful for a self-service configuration design.
Sorry if this example is too verbose or misses the point; the tldr is that i'd like a self-service client who is as decoupled as possible from the upstream gRPC service. Since the client already needs to know the incoming request path, I feel that should be enough to achieve the transcoding.
lizan commentedon Mar 20, 2018
Thanks @ilackarms.
The author of Envoy's config is alreay aware of the route on the upstream, since they needs to specify
services, and they can let thedescriptors.pbto decide what incoming request looks like. For example they can just route prefix/bookstore.Bookstore/to route the whole gRPC service to a cluster.In most cases, users use both native gRPC and JSON-gRPC transcoding at same time, in that case, route based on outgoing request are same for same service/method, i.e.
/bookstore.Bookstore/ListShelves.I partly agree this is a valid use case if the author of Envoy's config only cares about incoming request and don't use native-gRPC at all.
However I would still disagree with your change #2848, since current behavior that
routes are pre-calculate before HTTP filter chain and transcoder clears the cacheis not Envoy standard and not documented somewhere, it is just a implementation detail. This behavior might be changed in future Envoy version, this happened before.Looks like you want the author of Envoy's config to be focused on incoming request, there are other filters that clears route caches as well (like Lua filter, it does many things). So rather than add a flag to change the implementation behavior of gRPC-JSON transcoder as a "fix", I think adding a flag like
route_based_on_incoming_requestto [HTTP route config] is more appropriate for this case.WDYT? cc @mattklein123
mattklein123 commentedon Mar 20, 2018
Hmm. Would need to think about this more. I suppose we could add some type of option that locks the ingress route, but then filters would basically not work and I think that would be super confusing. i guess my gut feeling is to make this an option on a per-filter basis if it makes sense to do so.
lizan commentedon Mar 20, 2018
I'm OK to doing per-filter basis. I thought it just confuses more in cases that some filter combinations would result random routing result. IMO having the option that locks the ingress route might confuses filter devs more, but confuses users less.
htuch commentedon Mar 21, 2018
I would also vote for per-filter, since I think we are going to provide surprising behavior to users in any case if we break filters that can't handle route locking. This is the least surprising path IMHO.
gRPC/JSON transcoder: enable preserving route after headers modified (#…
htuch commentedon Apr 10, 2018
I think this is resolved in #2848, please reopen if not.
yangyangpig commentedon Jun 6, 2019
mark