Skip to content
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

Merged
merged 4 commits into from
Feb 6, 2018

Conversation

mrice32
Copy link
Member

@mrice32 mrice32 commented Feb 4, 2018

Description:
Expose the path match string as well as the type (regex, exact match, or prefix) through RouteEntry using a new object called PathMatchCriterion for the purpose of using this information in access logs.

Risk Level: Low

Testing: Unit tested getters.

Copy link
Member

@htuch htuch left a 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.

@htuch htuch self-assigned this Feb 5, 2018
@mattklein123
Copy link
Member

@mattklein123 thoughts here? Seems it would be useful to persist xDS config for other reasons, such as #2421.

Sure, either way.

@@ -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; }
Copy link
Member

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?).

Copy link
Member Author

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?

Copy link
Member

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.

Copy link
Member Author

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();
Copy link
Member

Choose a reason for hiding this comment

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

Nit: const etc.

Copy link
Member

@htuch htuch left a 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.

@htuch htuch merged commit b73444c into envoyproxy:master Feb 6, 2018
@mrice32 mrice32 deleted the route_match_type branch February 6, 2018 04:38
Shikugawa pushed a commit to Shikugawa/envoy that referenced this pull request Mar 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants