Fixed 58441, RegularExpression routes incorrectly ranked below PathPr…#58641
Fixed 58441, RegularExpression routes incorrectly ranked below PathPr…#58641vibhordubey333 wants to merge 3 commits intoistio:masterfrom
Conversation
|
😊 Welcome @vibhordubey333! This is either your first contribution to the Istio istio repo, or it's been You can learn more about the Istio working groups, Code of Conduct, and contribution guidelines Thanks for contributing! Courtesy of your friendly welcome wagon. |
|
Hi @vibhordubey333. Thanks for your PR. I'm waiting for a github.com member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. |
|
/ok-to-test |
|
/retest |
This is not really true. The Gateway API semantics are implementation specific, meaning we can order it however we want. And changing it is definitely a breaking change. |
|
The main argument for regex having higher priority is that it allows you to make 'prefix: /' be a catch all path. That said, we can achieve the same with 'regex: /.*'. So the most we gain with this change is matching envoy gateway's behavior. And maybe having 'prefix: /' be a catch all path is slightly more intuitive. |
Will incorporate the review comment. |
|
🚧 This issue or pull request has been closed due to not having had activity from an Istio team member since 2025-12-29. If you feel this issue or pull request deserves attention, please reopen the issue. Please see this wiki page for more information. Thank you for your contributions. Created by the issue and PR lifecycle manager. |
Please provide a description of this PR:
Issue: #58441
Bug Fix: RegularExpression routes incorrectly ranked below PathPrefix routes
Problem
When using Kubernetes Gateway API HTTPRoute resources with both
RegularExpressionandPathPrefixpath matches, requests are incorrectly routed to the less specific PathPrefix route instead of the more specific RegularExpression route.Example:
RegularExpression: "/api/test/[0-9a-z-]+"→ Service APathPrefix: "/api"→ Service BRequest to
/api/test/checkshould match Route A, but currently matches Route B.Root Cause
The
getURIRank()function incorrectly assigned ranks:Exact (3) > Prefix (2) > Regex (1)Exact (3) > Regex (2) > Prefix (1)This caused PathPrefix routes to be sorted before RegularExpression routes, so Envoy would always match the prefix route first, preventing the regex route from being evaluated.
Solution
Updated route ranking to prioritize RegularExpression over PathPrefix, ensuring more specific routes are evaluated first.
Changes
getURIRank()to assign correct ranksTesting
TestSortHTTPRoutesunit testImpact
Breaking Change: Yes - This fixes incorrect behavior and aligns with expected Gateway API semantics.
Investigation Steps:
istioctl proxy-config routesto inspect Envoy configgetURIRank()functionTo help us figure out who should review this PR, please put an X in all the areas that this PR affects.