envoy icon indicating copy to clipboard operation
envoy copied to clipboard

OnDemand VHDS makes the first request returns 404.

Open WeavingGao opened this issue 5 years ago • 11 comments

Description:

I used OnDemand VHDS to dynamically obtain the virtual host configuration. When a request to a certain host comes for the first time, the request of the route is nullptr, then the on demand filter will send a VHDS request, and execute its callback onRouteConfigUpdateCompletion when the VHDS response is received. If the request to the host doesn't have a body, it works fine because a new stream will be created and the request's route will be re-calculated. However if the request has a body, it won't re-create a stream but just continue to next filter, thus the request's route is still nullptr since the snapped_route_config_ is still the old one. Finally the router filter will send a local response of 404 to downstream and set the response flag to NR.

cc @dmitri-d @htuch @lambdai

WeavingGao avatar Aug 27 '21 07:08 WeavingGao

Ondemand route filter stall the HCM by returning Http::FilterHeadersStatus::StopIteration and recreateStream asynchronously to reevaluate the route. It depends on the functionality of HCM.

Maybe this filter can instead return one of StopAllIterationAndBuffer or StopAllIterationAndWatermark to stop the iteration? I feel a filter prior to this ondemand filter still have the chance to break, but these two is strictly better than StopIteration @alyssawilk Does the above make sense? Is there any other reliable approach to reevaluate route?

lambdai avatar Aug 27 '21 17:08 lambdai

On-demand/vhds supports requests without a body only at the moment.

It should be possible to do an internal redirect with a body now, provided envoy.reloadable_features.internal_redirects_with_body has been enabled and the request has been fully read (here: https://github.com/envoyproxy/envoy/blob/main/source/common/http/conn_manager_impl.cc#L1684)? In this case RouteConfig update will need to be initiated from OnDemandRouteUpdate::decodeData() when end_stream is received. @alyssawilk: did I get this right?

dmitri-d avatar Aug 27 '21 21:08 dmitri-d

Yeah, the router now supports internal redirects with a fully read body (https://github.com/envoyproxy/envoy/pull/15634) but the on demand filter does not yet use that new code (https://github.com/envoyproxy/envoy/blob/main/source/extensions/filters/http/on_demand/on_demand_update.cc#L63)

stopalliteration + explicit read disable might work for HTTP/1.1 downstream but due to how HTTP/2 buffering works, it will still end up with a body buffer and still trip checks in the on demand filter. I think adding support for fully read bodies (as the router filter now has) would be a cleaner next step.

alyssawilk avatar Aug 31 '21 15:08 alyssawilk

This issue has been automatically marked as stale because it has not had activity in the last 30 days. It will be closed in the next 7 days unless it is tagged "help wanted" or "no stalebot" or other activity occurs. Thank you for your contributions.

github-actions[bot] avatar Sep 30 '21 16:09 github-actions[bot]

This issue has been automatically closed because it has not had activity in the last 37 days. If this issue is still valid, please ping a maintainer and ask them to label it as "help wanted" or "no stalebot". Thank you for your contributions.

github-actions[bot] avatar Oct 07 '21 20:10 github-actions[bot]

On-demand/vhds supports requests without a body only at the moment.

It should be possible to do an internal redirect with a body now, provided envoy.reloadable_features.internal_redirects_with_body has been enabled and the request has been fully read (here: https://github.com/envoyproxy/envoy/blob/main/source/common/http/conn_manager_impl.cc#L1684)? In this case RouteConfig update will need to be initiated from OnDemandRouteUpdate::decodeData() when end_stream is received. @alyssawilk: did I get this right?

is this fixed now ?

uglycow avatar Jul 10 '22 15:07 uglycow

is this fixed now ?

maoyutao avatar Apr 08 '24 12:04 maoyutao

How's this going @alyssawilk any progress made on this?

sichan-vonage avatar Sep 05 '24 12:09 sichan-vonage

This is unassigned - no one has picked it up thusfar sorry

alyssawilk avatar Sep 09 '24 13:09 alyssawilk

Hey folks, since this bug has remained unresolved for over three years, I'm curious - how are you working around it to dynamically fetch virtual hosts? cc @alyssawilk @sichan-vonage @maoyutao @uglycow @WeavingGao @dmitri-d If there is no workaround, does this mean there is still no solid approach to NOT require users to predefine their egress dependencies of their service?

hochuenw-dd avatar Jan 31 '25 08:01 hochuenw-dd

Getting this problem fixed is very important to us, which means that we potentially we have funding available if someone with the right skill set wants to come forward with a proposal?? @alyssawilk @sichan-vonage @maoyutao @uglycow @WeavingGao @dmitri-d

steveohara avatar Aug 26 '25 14:08 steveohara