-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
rds: expose path match criterion via route entry #2531
Conversation
Signed-off-by: Matt Rice <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IDK, this goes back to our earlier internal discussion on whether we should just persist the entire RouteConfiguration
and make it available via const&
to the access log.
In this case, it's not that useful to be given the entire RouteConfiguration
, as you only want the matching bits, but the principle of just passing a reference to that part of the RouteConfiguration
could still hold, rather than having to recover this as some C++ type.
@mattklein123 thoughts here? Seems it would be useful to persist xDS config for other reasons, such as #2421.
Sure, either way. |
Signed-off-by: Matt Rice <[email protected]>
@@ -335,6 +336,7 @@ class RouteEntryImplBase : public RouteEntry, | |||
} | |||
bool includeVirtualHostRateLimits() const override { return include_vh_rate_limits_; } | |||
const envoy::api::v2::core::Metadata& metadata() const override { return metadata_; } | |||
const PathMatchCriterion& pathMatchCriterion() const override { return *this; } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering if I've forgotten how to read C++ :) Can you explain why this is needed (or even how it passes type checking?).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, so the inheritance structure is a little convoluted here. RouteEntryImplBase
inherits from RouteEntry
, Matchable
, and now PathMatchCriterion
(among others). It has three derived classes (PrefixRouteEntryImpl
, PathRouteEntryImpl
, and RegexRouteEntryImpl
) that implement the Matchable
and PathMatchCriterion
abstract methods since they implement all of the match-type specific logic. So, for the pathMatchCriterion()
method (part of the RouteEntry
interface), it just returns itself as the PathMatchCriterion
since it implements that interface. Does that help clarify things?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it ever need to be directly instantiated (i.e. be concrete)? Or do we only use derived classes? If the latter, it seems we don't need to define it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The intent of the class was to group the idea of a route match type and a matcher since one is needed to interpret the other (like a virtualized POD struct) - as opposed to polluting the RouteEntry interface (which is already starting to feel a little big) with a routeMatchType()
method and a routeMatchString()
method or something. I'm happy to promote them to the RouteEntry interface if that seems like a net gain, though.
ASSERT_NE(nullptr, route); | ||
auto route_entry = route->routeEntry(); | ||
ASSERT_NE(nullptr, route_entry); | ||
auto& match_criterion = route_entry->pathMatchCriterion(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: const etc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, just some minor comments.
Signed-off-by: Matt Rice <[email protected]>
Signed-off-by: Kuat Yessenov <[email protected]>
Description:
Expose the path match string as well as the type (regex, exact match, or prefix) through
RouteEntry
using a new object calledPathMatchCriterion
for the purpose of using this information in access logs.Risk Level: Low
Testing: Unit tested getters.