upstream: introduce PriorityStateManager, refactor EDS#3783
upstream: introduce PriorityStateManager, refactor EDS#3783alyssawilk merged 20 commits intoenvoyproxy:masterfrom dio:eds-priority
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>
alyssawilk
left a comment
There was a problem hiding this comment.
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
| } | ||
|
|
||
| auto& priority_state = priority_state_manager_->priority_state_; | ||
| priority_state.clear(); |
There was a problem hiding this comment.
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.
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.
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.
I believe per our == google style this should be private
|
|
||
| /** | ||
| * 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.
Sorry, can you clarify what you mean by this not being used at runtime?
There was a problem hiding this comment.
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.
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.
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! |
alyssawilk
left a comment
There was a problem hiding this comment.
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.
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.
&& 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! |
zuercher
left a comment
There was a problem hiding this comment.
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.
nit: Please add a note to the comment indicating when health_checker_flag is used.
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! |
alyssawilk
left a comment
There was a problem hiding this comment.
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
PriorityStateManagerto 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_assignmentfield toClusteras 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