-
Notifications
You must be signed in to change notification settings - Fork 5.1k
upstream: introduce PriorityStateManager, refactor EDS #3783
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
Conversation
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.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.
Cool! I think it'll be helpful to have some of this code complexity broken out. A couple of drive by comments from me before I vanish for the rest of the week :-)
source/common/upstream/eds.cc
Outdated
@@ -63,33 +59,28 @@ void EdsClusterImpl::onConfigUpdate(const ResourceVector& resources, const std:: | |||
throw EnvoyException(fmt::format("Unexpected EDS cluster (expecting {}): {}", cluster_name_, | |||
cluster_load_assignment.cluster_name())); | |||
} | |||
|
|||
auto& priority_state = priority_state_manager_->priority_state_; | |||
priority_state.clear(); |
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.
Isn't clearing and creating every time going to be more computationally expensive? It'd be good if we can do this refactor with minimal performance regression
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 taking a ref and clearing it out. Previously, the priority_state
is a local variable in this scope.
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.
Does it makes sense to make PriorityStateManager a local variable in onConfigUpdate? It would mean reverting the Config::Utility::checkLocalInfo
call, but other than that check, PSM isn't needed beyond the scope on onConfigUpdate.
// Returns the size of the current cluster priority state. | ||
size_t size() const { return priority_state_.size(); } | ||
|
||
PriorityState priority_state_; |
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 believe per our == google style this should be private
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.
👍
|
||
/** | ||
* Manages PriorityState of a cluster. PriorityState is a per-priority binding of a set of hosts | ||
* with its corresponding locality weight map. This is not used at runtime, but useful to store |
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.
Sorry, can you clarify what you mean by this not being used at runtime?
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.
Probably the wording is not right. I meant to say: it is configuration related only, not in data path.
if (locality_lb_endpoint.has_locality() && locality_lb_endpoint.has_load_balancing_weight()) { | ||
// TODO(dio): Add tests as per @alyssawilk's comment here | ||
// https://github.com/envoyproxy/envoy/pull/3261/files#r188292098 | ||
priority_state_[priority].second[locality_lb_endpoint.locality()] = |
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.
Interestingly this looks like it's covered, but there's a few other spots missing. It'd be great to have unit tests as part of this refactor.
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.
👍
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
@alyssawilk when you have time please do a more in-depth review 😄. Thank you! |
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.
Sorry for the delay - I was out last week. With a more thorough inspection it looks really solid! Only two other nits from me :-)
source/common/upstream/eds.cc
Outdated
health_status == envoy::api::v2::core::HealthStatus::DRAINING || | ||
health_status == envoy::api::v2::core::HealthStatus::TIMEOUT | ||
? absl::optional<Host::HealthFlag>(Host::HealthFlag::FAILED_EDS_HEALTH) | ||
: absl::nullopt); |
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.
Any reason to not do the health flag checks in the function?
} | ||
|
||
void PriorityStateManager::updateClusterPrioritySet( | ||
const uint32_t priority, HostVectorSharedPtr current_hosts, |
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.
&& current_hosts if we're going to take ownership?
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
@alyssawilk @zuercher thanks for your time for reviewing this code! I think I have addressed your comments. When you have time please have a look. Thank you! |
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.
Looks good to me. One small nit.
Network::Address::InstanceConstSharedPtr address, | ||
const envoy::api::v2::endpoint::LocalityLbEndpoints& locality_lb_endpoint, | ||
const envoy::api::v2::endpoint::LbEndpoint& lb_endpoint, | ||
const Upstream::Host::HealthFlag health_checker_flag); |
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: Please add a note to the comment indicating when health_checker_flag is used.
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.
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
Signed-off-by: Dhi Aurrahman <dio@rockybars.com>
@alyssawilk @zuercher Please let me know if there is anything else that I should change. Thanks! |
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 both for the general code clean up and the refactor to make PriorityStateManager local - I think it made it an even cleaner PR.
* origin/master: config: making v2-config-only a boolean flag (envoyproxy#3847) lc trie: add exclusive flag. (envoyproxy#3825) upstream: introduce PriorityStateManager, refactor EDS (envoyproxy#3783) test: deflaking header_integration_test (envoyproxy#3849) http: new style WebSockets, where headers and data are processed by the filter chain. (envoyproxy#3776) common: minor doc updates (envoyproxy#3845) fix master build (envoyproxy#3844) logging: Requiring details for RELEASE_ASSERT (envoyproxy#3842) test: add test for consistency of RawStatData internal memory representation (envoyproxy#3843) common: jittered backoff implementation (envoyproxy#3791) format: run buildifier on .bzl files. (envoyproxy#3824) Support mutable metadata for endpoints (envoyproxy#3814) test: deflaking a test, improving debugability (envoyproxy#3829) Update ApiConfigSource docs with grpc_services only for GRPC configs (envoyproxy#3834) Add hard-coded /hot_restart_version test (envoyproxy#3832) healthchecks: Add interval_jitter_percent healthcheck option (envoyproxy#3816) Signed-off-by: Snow Pettersen <snowp@squareup.com>
Opened #3856 to fix some off-the-end indexing in |
Description:
This patch introduces
PriorityStateManager
to manage priorities/hosts/localitiesas requirement prior updating the cluster's
PrioritySet
.Since most of the codes are taken from eds.cc, this patch also refactors EDS codes.
This is part of the effort on adding
load_assignment
field toCluster
as signalledin #3261.
Risk Level: Medium
Testing:
bazel test //test/...
Docs Changes: N/A
Release Notes: N/A
Signed-off-by: Dhi Aurrahman dio@rockybars.com