fix(wasm): resolve stale route_name in wasm context after reroute#3576
Open
Jing-ze wants to merge 2 commits intoalibaba:mainfrom
Open
fix(wasm): resolve stale route_name in wasm context after reroute#3576Jing-ze wants to merge 2 commits intoalibaba:mainfrom
Jing-ze wants to merge 2 commits intoalibaba:mainfrom
Conversation
- Add Go test for verifying wasm plugin matchRules work correctly after reroute - Include two ingress definitions simulating reroute scenario with header-based routing - Add transformer plugin to map query param to header triggering reroute - Add custom-response plugin to verify new route is matched and response returned - Cover issue alibaba#3571 to ensure fresh route name is used after route cache clear - Add corresponding yaml manifests for ingress and wasm plugin configurations
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Collaborator
Author
|
Need to update the envoy binary. |
Collaborator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Ⅰ. Describe what this PR did
After upgrading Envoy from 1.27 to 1.36 (Higress 2.2.0), the
ROUTE_NAMEproperty resolution in the wasm context returns stale route names afterclearRouteCache()is triggered by a preceding plugin (e.g., transformer with reroute). This causes subsequent plugins'matchRuleevaluation to fail, as they see the old route name instead of the re-evaluated one.Root Cause: In Envoy 1.36,
StreamInfoImpl::getRouteName()delegates toroute_->routeName(), butclearRouteCache()only clearscached_route_in ActiveStream — it does NOT updatestreamInfo().route_. The original code checkedinfo->getRouteName()first (which reads the stalestreamInfo().route_), so the second path viafilter_callbacks->route()(which correctly triggers route re-evaluation) was never reached.Fix: Swapped the resolution order in the
ROUTE_NAMEcase offindValue()incontext.cc:filter_callbacks->route()first — this triggersrefreshCachedRoute()when the route cache has been cleared, returning the correctly re-evaluated route.info->getRouteName()only whenfilter_callbacksis unavailable (e.g., during access log phase).Changes:
envoy/envoysubmodule to include the fix commit (43287ff203)WasmPluginsRerouteMatchRuleto reproduce and verify the fixⅡ. Does this pull request fix one issue?
fixes #3571
Ⅲ. Why don't you add test cases (unit test/integration test)?
An e2e conformance test has been added (
go-wasm-reroute-match-rule). It sets up:userIdto headerx-user-id(triggering reroute)x-user-id: 1header)Ⅳ. Describe how to verify it
run the e2e test: