From c121ee44fb734a2f28528a1badec09d27727460f Mon Sep 17 00:00:00 2001 From: Kuat Date: Tue, 9 Jan 2024 17:46:54 -0800 Subject: [PATCH] wasm: fix xds attribute support (#31620) Commit Message: wires xds attribute into wasm, follow-up to #31319 Additional Description: none Risk Level: low Testing: done Docs Changes: none Release Notes: none --- source/extensions/common/wasm/context.cc | 5 +++++ test/extensions/filters/http/wasm/test_data/metadata_rust.rs | 2 +- test/extensions/filters/http/wasm/test_data/test_cpp.cc | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/source/extensions/common/wasm/context.cc b/source/extensions/common/wasm/context.cc index 57c0c24146b9..8c51d0ac67b8 100644 --- a/source/extensions/common/wasm/context.cc +++ b/source/extensions/common/wasm/context.cc @@ -456,6 +456,11 @@ Context::findValue(absl::string_view name, Protobuf::Arena* arena, bool last) co // In order to delegate to the StreamActivation method, we have to set the // context properties to match the Wasm context properties in all callbacks // (e.g. onLog or onEncodeHeaders) for the duration of the call. + if (root_local_info_) { + local_info_ = root_local_info_; + } else if (plugin_) { + local_info_ = &plugin()->localInfo(); + } activation_info_ = info; activation_request_headers_ = request_headers_ ? request_headers_ : access_log_request_headers_; activation_response_headers_ = diff --git a/test/extensions/filters/http/wasm/test_data/metadata_rust.rs b/test/extensions/filters/http/wasm/test_data/metadata_rust.rs index ed1a6b403923..da95f60555c8 100644 --- a/test/extensions/filters/http/wasm/test_data/metadata_rust.rs +++ b/test/extensions/filters/http/wasm/test_data/metadata_rust.rs @@ -30,7 +30,7 @@ impl Context for TestStream {} impl HttpContext for TestStream { fn on_http_request_headers(&mut self, _: usize, _: bool) -> Action { if self - .get_property(vec!["node", "metadata", "wasm_node_get_key"]) + .get_property(vec!["xds", "node", "metadata", "wasm_node_get_key"]) .is_none() { debug!("missing node metadata"); diff --git a/test/extensions/filters/http/wasm/test_data/test_cpp.cc b/test/extensions/filters/http/wasm/test_data/test_cpp.cc index 2bb3b9d1f8eb..e5952c8896f8 100644 --- a/test/extensions/filters/http/wasm/test_data/test_cpp.cc +++ b/test/extensions/filters/http/wasm/test_data/test_cpp.cc @@ -147,7 +147,7 @@ FilterHeadersStatus TestContext::onRequestHeaders(uint32_t, bool) { } } else if (test == "metadata") { std::string value; - if (!getValue({"node", "metadata", "wasm_node_get_key"}, &value)) { + if (!getValue({"xds", "node", "metadata", "wasm_node_get_key"}, &value)) { logDebug("missing node metadata"); } auto r = setFilterStateStringValue("wasm_request_set_key", "wasm_request_set_value");