Skip to content

wasm: fix multiple bug of vm key and plugin key calculation - #46893

Merged
wbpcode merged 3 commits into
envoyproxy:mainfrom
wbpcode:dev-unify-filter-factories-wasm
Aug 28, 2026
Merged

wbpcode merged 3 commits into
envoyproxy:mainfrom
wbpcode:dev-unify-filter-factories-wasm

Conversation

@wbpcode

@wbpcode wbpcode commented Aug 22, 2026 •

Copy link
Copy Markdown
Member

Commit Message: wasm: fix multiple bug of vm key and plugin key calculation
Additional Description:

This PR fixed tow bugs of wasm vm cache key and wasm plugin cache key:

  • now, the whole PluginConfig will be used to calculate the cache key. Before this change, the plugins with different allow_on_headers_stop_iteration may hit same cached plugin handle and make unexpected behavior.
  • now, the capability_restriction_config and runtime will be used to calculate the vm cache key. Before this change, the plugin VMs with different capability_restriction_config and runtime may hit same cache and result in unexpected behavior.

Now, we also removed the traffic direction from the plugin cache key. It's safe because it's unnecessary now.

Long time ago, before the #31365, we cannot extract the listener info from the connection info, so the WASM will get the traffic direction and listener metadata from the FactoryContext and store the reference at the cached plugin. Then when get_property ABI is used, the plugin could serve the related attributes.

And to avoid the wasm plugins that be configured in different listeners (with different direction/metadata) hit same plugin cache, we added the listener metadata and traffic direction in to plugin cache key calculation at #17243.

But at the #36619 , we have did a great refactoring and removed the dependencies to the traffic direction and listener metadata from the FactoryContext. The get_property ABI will get attributes from the stream info and stream level context. So, after that, it's unnecessary to use the listener metadata and traffic direction as cache key. And at the #36941, we removed the traffic direction and listener metadata from the cached plugin completely. After that, the traffic direction/metadata make nonsense in the cache key.

Risk Level: low.
Testing: n/a.
Docs Changes: n/a.
Release Notes: added.
Platform Specific Features: n/a.

@repokitteh-read-only

Copy link
Copy Markdown

CC @envoyproxy/api-shepherds: Your approval is needed for changes made to (api/envoy/|docs/root/api-docs/).
envoyproxy/api-shepherds assignee is @adisuissa
CC @envoyproxy/api-watchers: FYI only for changes made to (api/envoy/|docs/root/api-docs/).

🐱

Caused by: #46893 was opened by wbpcode.

see: more, trace.

@wbpcode wbpcode assigned kyessenov and unassigned adisuissa Aug 22, 2026
Signed-off-by: wbpcode <[email protected]>
@@ -0,0 +1,7 @@
The identity of a Wasm plugin (which plugin configurations share a single root context and
thread-local plugin instance inside a Wasm VM) is now derived from the whole
:ref:`plugin configuration <envoy_v3_api_msg_extensions.wasm.v3.PluginConfig>` instead of from the

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think instance sharing was intended because the same VM could receive multiple calls for on_configure. Are you sure this is safe to merge?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, it's safe. Note, we still shared plugin instance and VM instance if they have exactly same configuration. In our previous implementation, there actually a bug that result in unexpected instance be shared and finally result in unexpected behavior.
For example, in the previous implementation, two plugin configurations with different allow_on_headers_stop_iteration will hit same cache and only the first one's flag will take effects which is wrong.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I do notice that there were a bunch of "first config wins" problems. But the history here was that Envoy couldn't concurrently run large number of VMs during reconfiguration so it was a hack to make it work. I think this change makes it a bit more consistent with xDS, but it is a semantic change.

krinkinmu pushed a commit that referenced this pull request Aug 25, 2026
#46906)

Commit Message: istio stats: remove the dependency to the direction of
factory context
Additional Description:

Now, the the istio stats won't depends on the factory context's
trafficDirection(), like what we did at the
#46893

After all these filters be updated, we could remove the direction() from
the FactoryContext and the these filters also could works correctly at
cross-listeners shared filter chain (FCDS).

Risk Level: low.
Testing: n/a.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

---------

Signed-off-by: wbpcode <[email protected]>
@wbpcode
wbpcode requested a review from kyessenov August 27, 2026 03:48

@kyessenov kyessenov left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! cc @mpwarres - I believe this now treats plugin configuration as part of the key, disallowing repeated configuration calls on the same VM. I think that was the latest decision, and that's how it works in null VM.

@wbpcode

wbpcode commented Aug 28, 2026

Copy link
Copy Markdown
Member Author

gently ping for api review @adisuissa

@htuch htuch left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/lgtm api

@wbpcode
wbpcode merged commit d1fa432 into envoyproxy:main Aug 28, 2026
28 checks passed
@wbpcode
wbpcode deleted the dev-unify-filter-factories-wasm branch August 28, 2026 15:29
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
- reduce sharding and resource pools for wasm host tests
- split wasm filter test and test modules by concern
- only test first available engine in host tests (all engines still
tested in compile-time-options)
- additional tests to ensure coverage of runtime compilation

---------

Backport note: `getSha256Digest()` keeps this branch's `Buffer::Instance`
signature, `envoy_wasm_cc_binary` keeps its `@envoy//` string labels, and
the `VmCacheVmConfigChange`, `VmCacheDeprecatedCapabilityRestriction` and
`FilterConfigDeprecatedPluginLevelCapabilityRestriction` tests are left
out, as they test envoyproxy#46893, which is not on this branch.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit b50daf5)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
- reduce sharding and resource pools for wasm host tests
- split wasm filter test and test modules by concern
- only test first available engine in host tests (all engines still
tested in compile-time-options)
- additional tests to ensure coverage of runtime compilation

---------

Backport note: `getSha256Digest()` keeps this branch's `Buffer::Instance`
signature, `envoy_wasm_cc_binary` keeps its `@envoy//` string labels, the
proxy-wasm repositories keep this branch's names (`proxy_wasm_cpp_host`,
`proxy_wasm_cpp_sdk`), and
the `VmCacheVmConfigChange`, `VmCacheDeprecatedCapabilityRestriction` and
`FilterConfigDeprecatedPluginLevelCapabilityRestriction` tests are left
out, as they test envoyproxy#46893, which is not on this branch.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit b50daf5)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
- reduce sharding and resource pools for wasm host tests
- split wasm filter test and test modules by concern
- only test first available engine in host tests (all engines still
tested in compile-time-options)
- additional tests to ensure coverage of runtime compilation

---------

Backport note: `getSha256Digest()` keeps this branch's
`Buffer::Instance` signature, `Plugin` keeps its `TrafficDirection`
argument, `envoy_wasm_cc_binary` keeps its `@envoy//` string labels, the
proxy-wasm repositories keep this branch's names (`proxy_wasm_cpp_host`,
`proxy_wasm_cpp_sdk`), and the `VmCacheVmConfigChange`,
`VmCacheDeprecatedCapabilityRestriction` and
`FilterConfigDeprecatedPluginLevelCapabilityRestriction` tests are left
out, as they test envoyproxy#46893, which is not on this branch.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit b50daf5)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
- reduce sharding and resource pools for wasm host tests
- split wasm filter test and test modules by concern
- only test first available engine in host tests (all engines still
tested in compile-time-options)
- additional tests to ensure coverage of runtime compilation

---------

Backport note: as on release/v1.39, `getSha256Digest()` keeps this
branch's `Buffer::Instance` signature, `Plugin` keeps its
`TrafficDirection` argument, `envoy_wasm_cc_binary` keeps its `@envoy//`
string labels, the proxy-wasm repositories keep this branch's names, and
the tests for envoyproxy#46893 are left out. Also left out here are the tests for
changes not on this branch: the deferred data integration test and its
Rust module (envoyproxy#44279), `VmCacheEnvVarChange` (envoyproxy#44563) and the
`localWasmConfig()` config test helper (envoyproxy#45242). The filter tests keep
this branch's `absl::optional` and `absl::nullopt`, and `wee8_compile`
keeps its summary output.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit b50daf5)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
- reduce sharding and resource pools for wasm host tests
- split wasm filter test and test modules by concern
- only test first available engine in host tests (all engines still
tested in compile-time-options)
- additional tests to ensure coverage of runtime compilation

---------

Backport note: as on release/v1.39, `getSha256Digest()` keeps this
branch's `Buffer::Instance` signature, `Plugin` keeps its
`TrafficDirection` and (here) listener metadata arguments,
`envoy_wasm_cc_binary` keeps its `@envoy//` string labels, the
proxy-wasm repositories keep this branch's names, and the tests for
envoyproxy#46893 are left out. Also left out here are the tests for changes not on
this branch: the deferred data integration test and its Rust module
(envoyproxy#44279), `VmCacheEnvVarChange` (envoyproxy#44563) and the `localWasmConfig()`
config test helper (envoyproxy#45242). The filter tests keep this branch's
`absl::optional` and `absl::nullopt`, and `wee8_compile` keeps its
summary output.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit b50daf5)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
- reduce sharding and resource pools for wasm host tests
- split wasm filter test and test modules by concern
- only test first available engine in host tests (all engines still
tested in compile-time-options)
- additional tests to ensure coverage of runtime compilation

---------

Backport note: `getSha256Digest()` keeps this branch's
`Buffer::Instance` signature, `Plugin` keeps its `TrafficDirection`
argument, `envoy_wasm_cc_binary` keeps its `@envoy//` string labels, the
proxy-wasm repositories keep this branch's names (`proxy_wasm_cpp_host`,
`proxy_wasm_cpp_sdk`), and the `VmCacheVmConfigChange`,
`VmCacheDeprecatedCapabilityRestriction` and
`FilterConfigDeprecatedPluginLevelCapabilityRestriction` tests are left
out, as they test envoyproxy#46893, which is not on this branch.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit b50daf5)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
- reduce sharding and resource pools for wasm host tests
- split wasm filter test and test modules by concern
- only test first available engine in host tests (all engines still
tested in compile-time-options)
- additional tests to ensure coverage of runtime compilation

---------

Backport note: as on release/v1.39, `getSha256Digest()` keeps this
branch's `Buffer::Instance` signature, `Plugin` keeps its
`TrafficDirection` and (here) listener metadata arguments,
`envoy_wasm_cc_binary` keeps its `@envoy//` string labels, the
proxy-wasm repositories keep this branch's names, and the tests for
envoyproxy#46893 are left out. Also left out here are the tests for changes not on
this branch: the deferred data integration test and its Rust module
(envoyproxy#44279), `VmCacheEnvVarChange` (envoyproxy#44563) and the `localWasmConfig()`
config test helper (envoyproxy#45242). The filter tests keep this branch's
`absl::optional` and `absl::nullopt`, and `wee8_compile` keeps its
summary output.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit b50daf5)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 13, 2026
- reduce sharding and resource pools for wasm host tests
- split wasm filter test and test modules by concern
- only test first available engine in host tests (all engines still
tested in compile-time-options)
- additional tests to ensure coverage of runtime compilation

---------

Backport note: as on release/v1.39, `getSha256Digest()` keeps this
branch's `Buffer::Instance` signature, `Plugin` keeps its
`TrafficDirection` and (here) listener metadata arguments,
`envoy_wasm_cc_binary` keeps its `@envoy//` string labels, the
proxy-wasm repositories keep this branch's names, and the tests for
envoyproxy#46893 are left out. Also left out here are the tests for changes not on
this branch: the deferred data integration test and its Rust module
(envoyproxy#44279), `VmCacheEnvVarChange` (envoyproxy#44563) and the `localWasmConfig()`
config test helper (envoyproxy#45242). The tests keep this branch's
`absl::optional` and `absl::nullopt`, and `wee8_compile` keeps its
summary output.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit b50daf5)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
- reduce sharding and resource pools for wasm host tests
- split wasm filter test and test modules by concern
- only test first available engine in host tests (all engines still
tested in compile-time-options)
- additional tests to ensure coverage of runtime compilation

---------

Backport note: `getSha256Digest()` keeps this branch's
`Buffer::Instance` signature, `Plugin` keeps its `TrafficDirection`
argument, `envoy_wasm_cc_binary` keeps its `@envoy//` string labels, the
proxy-wasm repositories keep this branch's names (`proxy_wasm_cpp_host`,
`proxy_wasm_cpp_sdk`), and the `VmCacheVmConfigChange`,
`VmCacheDeprecatedCapabilityRestriction` and
`FilterConfigDeprecatedPluginLevelCapabilityRestriction` tests are left
out, as they test envoyproxy#46893, which is not on this branch.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit b50daf5)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit to phlax/envoy that referenced this pull request Nov 17, 2026
- reduce sharding and resource pools for wasm host tests
- split wasm filter test and test modules by concern
- only test first available engine in host tests (all engines still
tested in compile-time-options)
- additional tests to ensure coverage of runtime compilation

---------

Backport note: as on release/v1.39, `getSha256Digest()` keeps this
branch's `Buffer::Instance` signature, `Plugin` keeps its
`TrafficDirection` and (here) listener metadata arguments,
`envoy_wasm_cc_binary` keeps its `@envoy//` string labels, the
proxy-wasm repositories keep this branch's names, and the tests for
envoyproxy#46893 are left out. Also left out here are the tests for changes not on
this branch: the deferred data integration test and its Rust module
(envoyproxy#44279), `VmCacheEnvVarChange` (envoyproxy#44563) and the `localWasmConfig()`
config test helper (envoyproxy#45242). The tests keep this branch's
`absl::optional` and `absl::nullopt`, and `wee8_compile` keeps its
summary output.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit b50daf5)
Signed-off-by: Ryan Northey <[email protected]>
phlax added a commit that referenced this pull request Nov 17, 2026
- reduce sharding and resource pools for wasm host tests
- split wasm filter test and test modules by concern
- only test first available engine in host tests (all engines still
tested in compile-time-options)
- additional tests to ensure coverage of runtime compilation

---------

Backport note: as on release/v1.39, `getSha256Digest()` keeps this
branch's `Buffer::Instance` signature, `Plugin` keeps its
`TrafficDirection` and (here) listener metadata arguments,
`envoy_wasm_cc_binary` keeps its `@envoy//` string labels, the
proxy-wasm repositories keep this branch's names, and the tests for
#46893 are left out. Also left out here are the tests for changes not on
this branch: the deferred data integration test and its Rust module
(#44279), `VmCacheEnvVarChange` (#44563) and the `localWasmConfig()`
config test helper (#45242). The tests keep this branch's
`absl::optional` and `absl::nullopt`, and `wee8_compile` keeps its
summary output.

Signed-off-by: Ryan Northey <[email protected]>
(cherry picked from commit b50daf5)
Signed-off-by: Ryan Northey <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants