-
Notifications
You must be signed in to change notification settings - Fork 5.5k
upstream: make sure all_hosts_ is updated correctly #4575
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 4 commits
0ad25a5
232006b
4e8c0b9
feb0fba
f6ac401
f2146af
f3e1e5d
97cf9d5
c32348f
2490830
e3c0de0
95510b5
a1d2995
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 |
|---|---|---|
|
|
@@ -1127,10 +1127,17 @@ void StrictDnsClusterImpl::updateAllHosts(const HostVector& hosts_added, | |
| // At this point we know that we are different so make a new host list and notify. | ||
| for (const ResolveTargetPtr& target : resolve_targets_) { | ||
| priority_state_manager.initializePriorityFor(target->locality_lb_endpoint_); | ||
| for (const HostSharedPtr& host : target->hosts_) { | ||
| if (target->locality_lb_endpoint_.priority() == current_priority) { | ||
| priority_state_manager.registerHostForPriority(host, target->locality_lb_endpoint_, | ||
| target->lb_endpoint_, absl::nullopt); | ||
| std::unordered_set<std::string> host_addresses; | ||
| if (target->locality_lb_endpoint_.priority() == current_priority) { | ||
| for (auto i = target->hosts_.begin(); i != target->hosts_.end();) { | ||
| if (host_addresses.count((*i)->address()->asString()) == 0) { | ||
| priority_state_manager.registerHostForPriority(*i, target->locality_lb_endpoint_, | ||
| target->lb_endpoint_, absl::nullopt); | ||
| host_addresses.insert((*i)->address()->asString()); | ||
| ++i; | ||
| } else { | ||
| i = target->hosts_.erase(i); | ||
|
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. In the case of multiple instances of the same host, you could probably save yourself a few calls to
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. remove_if doesn't work on associative containers so that won't work.
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. @lizan
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. ah ignore my comment above, I thought it is about host_addresses (unordered_set) |
||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
@@ -1193,6 +1200,14 @@ void StrictDnsClusterImpl::ResolveTarget::startResolve() { | |
| parent_.updateAllHosts(hosts_added, hosts_removed, locality_lb_endpoint_.priority()); | ||
| } | ||
|
|
||
| // TODO(dio): Not sure if we should do this if active health checking is disabled. | ||
|
Contributor
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. we should, the |
||
| if (parent_.health_checker_ != nullptr) { | ||
| for (const auto& set : parent_.prioritySet().hostSetsPerPriority()) { | ||
| for (const auto& host : set->hosts()) { | ||
| updated_hosts.insert({host->address()->asString(), host}); | ||
| } | ||
| } | ||
| } | ||
| parent_.updateHostMap(std::move(updated_hosts)); | ||
|
|
||
| // If there is an initialize callback, fire it now. Note that if the cluster refers to | ||
|
|
||
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 a little confused on what the underlying bug actually is here. Can you add more comments so it's easier to understand what this code is doing now? Also, should whatever this is doing actually be done inside the priority state manager so it applies to all discovery types? Is this related to @snowp's comment in the issue around reconciling DNS with EDS behavior? Maybe the comments will help me understand more. Feel free to leave TODOs on what else needs to be done later. Thank you!
Uh oh!
There was an error while loading. Please reload this page.
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.
Sure will add more comments here. While I think this dedupe here probably is not required anymore since the underlying problem is indeed when we update the internal
all_hosts_data (for EDS (STATIC), the updated hosts consist of all host sets, while for STRICT_DNS it is not, depends on each DNS resolution). This:envoy/source/common/upstream/upstream_impl.cc
Lines 1208 to 1213 in e3c0de0
Will make sure the priority state manager can actually handle this (no duplications).
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.
@mattklein123 for following up this issue, I have opened one here: #4590 to track. This is based on @snowp's comment. I'll take a look at that later.