Implement basic route matching for xDS clients - #6333
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #6333 +/- ##
===========================================
Coverage 74.46% 74.46%
- Complexity 22234 22694 +460
===========================================
Files 1963 2031 +68
Lines 82437 84336 +1899
Branches 10764 11000 +236
===========================================
+ Hits 61385 62803 +1418
- Misses 15918 16279 +361
- Partials 5134 5254 +120 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
a0e8543 to
875f64d
Compare
14effb3 to
13fa4fe
Compare
| final String joined = COMMA_JOINER.join(allHeaders); | ||
| return stringMatcher.match(joined); |
There was a problem hiding this comment.
Noted, the order of header values is crucial to match multiple headers.
| final StringMatcherImpl matcherImpl = new StringMatcherImpl(matcher); | ||
| predicate = ctx -> matcherImpl.match(ctx.path()); | ||
| } else if (pathSpecifierCase == PathSpecifierCase.CONNECT_MATCHER) { | ||
| predicate = ctx -> ctx.method() == HttpMethod.CONNECT; |
There was a problem hiding this comment.
Note that this will not match other Extended CONNECT requests (WebSocket and the like) as they are normalized in Envoy as HTTP/1.1 style upgrades.
I understand that the CONNECT_MATCHER implementation does not follow the Envoy's specification, as CONNECT is used for WebSocket in Armeria.
There was a problem hiding this comment.
CONNECT is used for WebSocket in Armeria.
I don't really see a difference since for HTTP1 CONNECT isn't used either (and http2 websockets aren't supported in envoy).
Nuances on the request state may differ, but the condition is more or less the same.
Motivation:
Following #6322, this changeset attempts to implement route matching (
Route#match).ref: https://www.envoyproxy.io/docs/envoy/latest/api-v3/config/route/v3/route_components.proto#envoy-v3-api-msg-config-route-v3-route
Implementation is focused on following upstream behavior as closely as possible.
The corresponding implementation can be found here: https://github.com/envoyproxy/envoy/blob/4bb05db55ecd583b6f451d81445d94210445176f/source/common/router/config_impl.cc#L831-L881
Matching rules that aren't implemented are:
Overall, the above rules have been verified to not being used in basic istio cases.
Modifications:
RouteEntryMatcherwhich matches a route based on the path, headers and query parameters.re2j, which provides linear time regex matching.re2jinbootstrap#default_regex_engine.gitignoresince it seems like other major repositories aren't checking in this file either.Result: