Skip to content
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

Merged
merged 2 commits into from
Jul 25, 2024

Conversation

jrhee17
Copy link
Contributor

@jrhee17 jrhee17 commented Jul 5, 2024

Motivation:

It seems inconsistent that Endpoint#withAttr merges the attribute to the existing attributes, whereas Endpoint#withAttrs simply replaces the previous attributes.
I propose that we modify the behavior of Endpoint#withAttrs to be aligned with Endpoint#withAttr. Additionally, in order to support the previous behavior, I propose a new API Endpoint#replaceAttrs be added.

I've confirmed that there are no uses of this API at least internally.

ref: #5785 (comment)

Modifications:

  • Modified the behavior of Endpoint#withAttrs to merge attributes
  • Added a new API Endpoint#replaceAttrs to support the previous behavior

Result:

Copy link

codecov bot commented Jul 5, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 74.76%. Comparing base (e08527d) to head (b2d3d2c).
Report is 12 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

@jrhee17 jrhee17 marked this pull request as ready for review July 8, 2024 01:10
Copy link
Member

@minwoox minwoox left a 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) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@UnstableApi

@jrhee17 jrhee17 mentioned this pull request Jul 9, 2024
Copy link
Contributor

@ikhoon ikhoon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sense. 👍👍

@ikhoon ikhoon merged commit d793ade into line:main Jul 25, 2024
14 of 15 checks passed
jrhee17 added a commit that referenced this pull request Aug 8, 2024
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
-->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants