-
Notifications
You must be signed in to change notification settings - Fork 914
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
Modify behavior of Endpoint#withAttrs
to merge attributes
#5802
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #5802 +/- ##
============================================
+ Coverage 74.75% 74.76% +0.01%
- Complexity 21409 21421 +12
============================================
Files 1877 1877
Lines 79126 79170 +44
Branches 10201 10208 +7
============================================
+ Hits 59152 59195 +43
- Misses 15179 15182 +3
+ Partials 4795 4793 -2 ☔ View full report in Codecov by Sentry. |
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.
👍 👍 👍
* in {@param newAttributes} has higher precedence. | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
public Endpoint withAttrs(Attributes newAttributes) { |
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.
@UnstableApi
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.
Make sense. 👍👍
Motivation: It is recommended to review #5802 prior to this PR This changeset attempts to solve several problems: ##### Custom filter logic xDS considers all endpoints when computing whether a `PrioritySet` is in panic state. For instance, if the percentage of unhealthy endpoints exceeds a preconfigured panic threshold, the endpoint selection includes all endpoints regardless of the degraded status. While armeria supports an `HealthCheckedEndpointGroup` out of the box, it filters out healthy endpoints automatically. - https://github.com/line/armeria/blob/72ebfe12abf7804723a490fe7acfe3a45d46089f/xds/src/main/java/com/linecorp/armeria/xds/client/endpoint/DefaultLoadBalancer.java#L99-L105 - ref: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/panic_threshold In order to resolve this, I propose that a `AbstractHealthCheckedEndpointGroupBuilder#healthCheckedEndpointPredicate` API is added ##### Per-cluster health check configuration Per-cluster member health check is difficult with the current API since a single parameter set is statically defined for an entire health checked endpoint group. - ref: https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/health_checking#per-cluster-member-health-check-config We already have an abstraction `AbstractHealthCheckedEndpointGroupBuilder#newCheckerFactory`. I propose that this API be used for the purpose of xDS. In order to support the parameters xDS allows configuring, I propose that parameters are passed to `HttpHealthChecker` via the constructor instead of the `HealthCheckerContext`. In order to support this change, `HttpHealthChecker` has been moved to an internal package so the `xds` module can also access it. Modifications: - Added APIs `AbstractHealthCheckedEndpointGroupBuilder#healthCheckedEndpointPredicate` and modified `HealthCheckedEndpointGroup` to filter endpoints based on the predicate. - Health checked `Endpoint`s now have attributes `HEALTHY` and `DEGRADED` set. - `HealthCheckedEndpointGroup#setEndpoints` is now called on every invocation of `updateHealth`, not just when a health status changes. - xDS sometimes needs to override the health checked `Endpoint`, so modified to receive health checked parameters from the `HttpHealthChecker` constructor instead of `HealthCheckerContext`. - In the process, `HttpHealthChecker` has been moved to an internal package - `HealthCheckerContext#originalEndpoint` has been added to retrieve the original endpoint. The other APIs haven't been deprecated since it is potentially useful information that other `HealthChecker`s may be using. - Introduced a `XdsHealthCheckedEndpointGroupBuilder` which implements its own `checkerFactory`. - `EndpointUtil#coarseHealth` has been updated to consider `HEALTHY`, `DEGRADED` attributes when determining health. Result: - The behavior of `XdsEndpointGroup` is more aligned with envoy in terms of health checking - Preparation for zone-aware load balancing <!-- Visit this URL to learn more about how to write a pull request description: https://armeria.dev/community/developer-guide#how-to-write-pull-request-description -->
Motivation:
It seems inconsistent that
Endpoint#withAttr
merges the attribute to the existing attributes, whereasEndpoint#withAttrs
simply replaces the previous attributes.I propose that we modify the behavior of
Endpoint#withAttrs
to be aligned withEndpoint#withAttr
. Additionally, in order to support the previous behavior, I propose a new APIEndpoint#replaceAttrs
be added.I've confirmed that there are no uses of this API at least internally.
ref: #5785 (comment)
Modifications:
Endpoint#withAttrs
to merge attributesEndpoint#replaceAttrs
to support the previous behaviorResult: