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

Clusterinfo consistency #4600

Merged
merged 9 commits into from
Oct 8, 2018

Conversation

stevenzzzz
Copy link
Contributor

@stevenzzzz stevenzzzz commented Oct 4, 2018

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:]

Xin Zhuang added 3 commits October 4, 2018 16:34
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>
@stevenzzzz
Copy link
Contributor Author

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

Copy link
Member

@mattklein123 mattklein123 left a 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:

  1. Looks like CI is broken, can you take a look?
  2. 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.

* 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.
Copy link
Member

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -111,6 +112,13 @@ class StreamFilterCallbacks {
*/
virtual Router::RouteConstSharedPtr route() PURE;

/**
* Returns the clusterInfo for the current request.
Copy link
Member

Choose a reason for hiding this comment

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

s/request/cached route

Copy link
Contributor Author

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

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.

Copy link
Contributor Author

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

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?

Copy link
Contributor Author

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?

Copy link
Member

Choose a reason for hiding this comment

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

Right, sorry, makes sense.

Copy link
Contributor Author

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>
@stevenzzzz
Copy link
Contributor Author

stevenzzzz commented Oct 5, 2018

Hey @mattklein123 Matt, I want to make the switch in another PR if that's fine by you?

@mattklein123
Copy link
Member

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?

@stevenzzzz
Copy link
Contributor Author

sure thing. :)
I found there is another similar cache route implementation, but at network filter layer: https://github.com/envoyproxy/envoy/blob/master/source/extensions/filters/network/thrift_proxy/conn_manager.cc
I think we want to do the same thing there?

@mattklein123
Copy link
Member

I think we want to do the same thing there?

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>
@stevenzzzz
Copy link
Contributor Author

wow, so all I did is:
git checkout master
git pull upstream master
git checkout feature-branch
git merge master
git commit
git push origin

Annnd there are 160+ files in my PR. Which I think most changes are in sync with master HEAD but shown as diff here.
Sorry for the mess, I need some git help to figure out what happened.

@stevenzzzz stevenzzzz closed this Oct 5, 2018
@stevenzzzz stevenzzzz reopened this Oct 5, 2018
Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com>
@mattklein123
Copy link
Member

@stevenzzzz please check CI

Xin Zhuang added 2 commits October 8, 2018 10:19
Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com>
merge master.

Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com>
Copy link
Contributor Author

@stevenzzzz stevenzzzz left a 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()) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

ack

Copy link
Member

@mattklein123 mattklein123 left a 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;
Copy link
Member

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

Copy link
Contributor Author

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.

Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com>
Copy link
Contributor Author

@stevenzzzz stevenzzzz left a 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;
Copy link
Contributor Author

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.

Copy link
Member

@mattklein123 mattklein123 left a 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!

@mattklein123 mattklein123 merged commit c5be849 into envoyproxy:master Oct 8, 2018
aa-stripe pushed a commit to aa-stripe/envoy that referenced this pull request Oct 11, 2018
Signed-off-by: Xin Zhuang <stevenzzz@stevenzzz6.cam.corp.google.com>
Signed-off-by: Aaltan Ahmad <aa@stripe.com>
@stevenzzzz stevenzzzz deleted the clusterinfo-consistency branch May 9, 2019 19:42
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.

2 participants