-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Support mutable metadata for endpoints #3814
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
Changes from 1 commit
bf002ff
8c7d6a6
f7b108f
15259b9
cabd88a
75294de
3b6ec60
0969f6b
3013e96
5aed1bb
cd8812e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -109,6 +109,11 @@ parseClusterSocketOptions(const envoy::api::v2::Cluster& config, | |
| return cluster_options; | ||
| } | ||
|
|
||
| bool metadataEq(const envoy::api::v2::core::Metadata& lhs, | ||
| const envoy::api::v2::core::Metadata& rhs) { | ||
| return Protobuf::util::MessageDifferencer::Equivalent(lhs, rhs); | ||
| } | ||
|
|
||
| } // namespace | ||
|
|
||
| Host::CreateConnectionData | ||
|
|
@@ -691,7 +696,7 @@ bool BaseDynamicClusterImpl::updateDynamicHostList(const HostVector& new_hosts, | |
| // TODO(htuch): We can be smarter about this potentially, and not force a full | ||
| // host set update on health status change. The way this would work is to | ||
| // implement a HealthChecker subclass that provides thread local health | ||
| // updates to the Cluster objeect. This will probably make sense to do in | ||
| // updates to the Cluster object. This will probably make sense to do in | ||
| // conjunction with https://github.com/envoyproxy/envoy/issues/2874. | ||
| bool health_changed = false; | ||
|
|
||
|
|
@@ -734,6 +739,15 @@ bool BaseDynamicClusterImpl::updateDynamicHostList(const HostVector& new_hosts, | |
| } | ||
| } | ||
|
|
||
| // Did metadata change? | ||
| if (!metadataEq(host->metadata(), (*i)->metadata())) { | ||
| (*i)->metadata(host->metadata()); | ||
| (*i)->canary(host->canary()); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems odd here to do the canary update inside the metadata check. Should this be an independent check for people that use canary but not metadata?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mattklein123 my thinking is that canary is encoded under
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Hmm. 2 questions:
Thoughts? Whatever we decide we should add more comments here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So for: Question 1: That is, it's just a metadata change as everything else and it needs to be updated so that subsets can be properly recreated. Was this what you were asking? I suspect maybe not... Question 2: And yeah, I'll add more comments too. Lets clear up question 1. before we move forward though.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should the metadata shared ptr be TLS and we post updates to it, which will then be applied on individual worker threads outside other processing? I think we would still want to latch where you suggest, but we could avoid having to take mutexes and worry about overlap with other execution by doing this.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Another alternative might be to treat metadata differences as different hosts -- push a new host with the new metadata into hosts_added and have the old one appear in hosts_removed? I think then we don't have to mess with locking?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Yeah, this occurred to me also. If this ends up getting super complicated (which it seems to be) I think we might want to consider this approach. Basically just consider this a new host and do a remove/add operation.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, intuitively I rather not treat this as remove/add... Sounds more heavy-handed than needed. So do you really think it's too complicated as is now? Shall we explore the remove/add route then? FWIW, I am testing the current version of this patch now since we really really really need mutable metadata for our setup.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I will review your current iteration in a bit. Let's hold here for now until we can review. Thanks for iterating on this. :) |
||
|
|
||
| // If metadata changed, we need to rebuild. See github issue #3810. | ||
| health_changed = true; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Probably should rename this var to reflect that it's tracking changes to more than just health. |
||
| } | ||
|
|
||
| (*i)->weight(host->weight()); | ||
| final_hosts.push_back(*i); | ||
| i = current_hosts.erase(i); | ||
|
|
||
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 would just inline the call since it's only used once.