-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Clusterinfo consistency #4600
Clusterinfo consistency #4600
Conversation
Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com>
Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com>
Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com>
@mattklein123 Hey Matt PTAL and see if it's okay. (I made it to be always on as I don't think it should be off when we have the API). |
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.
This looks like it's on the right track. Flushing out a few comments. Two things:
- Looks like CI is broken, can you take a look?
- Can you look at our built-in filters and see where you can use the new cached calls instead of an additional lookup? Quite a bit of cleanup is possible I think.
include/envoy/http/filter.h
Outdated
* Returns the clusterInfo for the current request. | ||
* This method is to avoid multiple look ups in the filter chain, it also provides a consistent | ||
* view of clusterInfo after a route is picked/repicked. | ||
* NOTE: Cached clusterInfo and route should be updated the same time. |
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.
s/should be/will be
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.
done
include/envoy/http/filter.h
Outdated
@@ -111,6 +112,13 @@ class StreamFilterCallbacks { | |||
*/ | |||
virtual Router::RouteConstSharedPtr route() PURE; | |||
|
|||
/** | |||
* Returns the clusterInfo for the current request. |
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.
s/request/cached route
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.
done
} else { | ||
Upstream::ThreadLocalCluster* local_cluster = | ||
connection_manager_.cluster_manager_.get(route->routeEntry()->clusterName()); | ||
cached_cluster_info_ = local_cluster->info(); |
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.
local_cluster can be nullptr. Please add test that covers this case.
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.
Thanks for the catch.
@@ -1477,8 +1484,17 @@ Tracing::Span& ConnectionManagerImpl::ActiveStreamFilterBase::activeSpan() { | |||
|
|||
Tracing::Config& ConnectionManagerImpl::ActiveStreamFilterBase::tracingConfig() { return parent_; } | |||
|
|||
Upstream::ClusterInfoConstSharedPtr ConnectionManagerImpl::ActiveStreamFilterBase::clusterInfo() { | |||
// NOTE: Refreshing route caches clusterInfo as well. | |||
if (!parent_.cached_route_.has_value()) { |
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 don't think this is necessary as we don't do this for the route call. The HCM will initialize the cache before calling any filters?
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 think we did the same for route(), see route() right below?
I think the cached_cluster_info has the same position as the cached_route. Say after an entity clearRouteCache and a fitler wants to access clusterInfo without knowing that, that could be a problem?
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.
Right, sorry, makes sense.
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.
ack
…no cluster' cached_cluster_info test case Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com>
Hey @mattklein123 Matt, I want to make the switch in another PR if that's fine by you? |
Do you promise you will do a follow up PR right after this one? Can you please also merge master? |
sure thing. :) |
cc @zuercher ^. Yeah we likely do but I wouldn't worry about it right now. |
Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com>
wow, so all I did is: Annnd there are 160+ files in my PR. Which I think most changes are in sync with master HEAD but shown as diff here. |
Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com>
@stevenzzzz please check CI |
Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com>
merge master. Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com>
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.
@stevenzzzz please check CI
Thanks! Fixed a bug. CI should be happy now.
@@ -1477,8 +1484,17 @@ Tracing::Span& ConnectionManagerImpl::ActiveStreamFilterBase::activeSpan() { | |||
|
|||
Tracing::Config& ConnectionManagerImpl::ActiveStreamFilterBase::tracingConfig() { return parent_; } | |||
|
|||
Upstream::ClusterInfoConstSharedPtr ConnectionManagerImpl::ActiveStreamFilterBase::clusterInfo() { | |||
// NOTE: Refreshing route caches clusterInfo as well. | |||
if (!parent_.cached_route_.has_value()) { |
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.
ack
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, thanks. Small nit. Reminder that you promised to do the filter cleanup right after this PR. :)
* view of clusterInfo after a route is picked/repicked. | ||
* NOTE: Cached clusterInfo and route will be updated the same time. | ||
*/ | ||
virtual Upstream::ClusterInfoConstSharedPtr clusterInfo() PURE; |
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: newline after this line
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.
done. Thought fix_format would catch 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.
Thanks for the reminder. working on filter cleanup after this PR.
* view of clusterInfo after a route is picked/repicked. | ||
* NOTE: Cached clusterInfo and route will be updated the same time. | ||
*/ | ||
virtual Upstream::ClusterInfoConstSharedPtr clusterInfo() PURE; |
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.
done. Thought fix_format would catch 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.
Thanks. I opened #4643 to track the follow up. Thank you!
Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com> Signed-off-by: Aaltan Ahmad <aa@stripe.com>
Description:
Cache threadlocalCluster.info in ActiveStream and open it to filters via StreamFilterCallbacks.
Risk Level: Low (nobody uses it).
Testing: unit tests.
Docs Changes:
Release Notes:
[Optional Fixes #Issue] #4558
[Optional Deprecated:]