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

ABI to customize upstream/origin selection #16

Open
ElvinEfendi opened this issue Dec 2, 2020 · 2 comments · Fixed by envoyproxy/envoy#14318
Open

ABI to customize upstream/origin selection #16

ElvinEfendi opened this issue Dec 2, 2020 · 2 comments · Fixed by envoyproxy/envoy#14318

Comments

@ElvinEfendi
Copy link

ElvinEfendi commented Dec 2, 2020

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

@PiotrSikora
Copy link
Contributor

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.

PiotrSikora added a commit to PiotrSikora/envoy that referenced this issue Dec 8, 2020
Proxy-Wasm ABI v0.1.0 has a dedicated call for clearing route cache
(proxy_clear_route_cache).

Proxy-Wasm ABI v0.2.0 removed it in favor of automatically clearing
route cache, but that part was never implemented in Envoy.

Partially fixes proxy-wasm/spec#16.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
lizan pushed a commit to envoyproxy/envoy that referenced this issue Dec 15, 2020
Proxy-Wasm ABI v0.1.0 has a dedicated call for clearing route cache
(proxy_clear_route_cache).

Proxy-Wasm ABI v0.2.0 removed it in favor of automatically clearing
route cache, but that part was never implemented in Envoy.

Partially fixes proxy-wasm/spec#16.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
@FeiYing9
Copy link

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

rexengineering pushed a commit to rexengineering/istio-envoy that referenced this issue Oct 15, 2021
Proxy-Wasm ABI v0.1.0 has a dedicated call for clearing route cache
(proxy_clear_route_cache).

Proxy-Wasm ABI v0.2.0 removed it in favor of automatically clearing
route cache, but that part was never implemented in Envoy.

Partially fixes proxy-wasm/spec#16.

Signed-off-by: Piotr Sikora <piotrsikora@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants