spec
spec copied to clipboard
ABI to customize upstream/origin selection
EDIT1: The example code for reproducing is at https://github.com/ElvinEfendi/envoy-wasm-regional-routing.
I have been experimenting with https://github.com/proxy-wasm/proxy-wasm-rust-sdk recently. I want to write a filter that for a given request, dynamically picks what Envoy cluster the request should be proxied to.
I tried using cluster_header: region
routing functionality of Envoy and was hoping I could dynamically change the header value in the plugin. But that did not work as I expected. Turns out self.set_http_request_header(&"region", Some(&"us_central1"));
changes/sets the header only for the upstream. Envoy's router does not see the updated value when making routing decision.
Is this an expected behaviour? If so, is there any plan to introduce a dedicated ABI for customizing Envoy's routing decision when it comes to upstream/cluster selection?
FWIW this seems to be possible with a Lua filter: https://medium.com/safetycultureengineering/edge-routing-with-envoy-and-lua-621f3d776c57
Thanks for adding the reproducer, it was really helpful.
The issue is that your code is missing a call to self.clear_http_route_cache()
after setting the new header value. The routing table should be flushed automatically after modifying the headers (which is the case with Lua), but it looks that we never got around to implementing it. I'll get that fixed, but in the meantime self.clear_http_route_cache()
works fine.
Answering your original question, the ABI will indeed have dedicated call to select upstream, but it's not there yet.
Answering your original question, the ABI will indeed have dedicated call to select upstream, but it's not there yet.
I'm really looking forward to this feature