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
Fix to support for dividing an upstream cluster into subsets using metadata in XdsEndpointGroup. #5461
Conversation
…tadata in XdsEndpointGroup. Motivation: Envoy allows configuring subsets for an upstream cluster using metadata. Subsets are defined based on metadata associated with each endpoint, and configurations within `lb_subset_config` and `metadata_match` in the `Cluster` and `RouteConfiguration` respectively. This enhancement ensures compatibility with Envoy's subset configuration capabilities, facilitating more granular load balancing. [Load Balancer Subsets](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/subsets) Modifications: - Introduce functionality in `XdsEndpointGroup` to divide an upstream cluster into subsets based on metadata. - Add `XdsBootstrap.listenerRoot(Listener)` to create a listener root with a static listener resource. Result: - You can now divide an upstream cluster into subsets effectively within `XdsEndpointGroup`, enabling more sophisticated load balancing configurations.
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.
Left two minor questions but overall looks good 👍
xds/src/main/java/com/linecorp/armeria/xds/XdsConverterUtil.java
Outdated
Show resolved
Hide resolved
return; | ||
} | ||
final LbSubsetFallbackPolicy fallbackPolicy = lbSubsetConfig.getFallbackPolicy(); | ||
if (fallbackPolicy != LbSubsetFallbackPolicy.ANY_ENDPOINT) { |
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.
Note: I guess no need to handle this in this PR, but this setting can technically be overridden by LbSubsetSelector#getFallbackPolicy
which can make this a false-positive warning.
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.
Yeah, let's handle it in another PR. I didn't implement the feature fully. 😉
One more question (although not directly related to this PR) I understood that certain projects may need to customize |
* in the tree are updated. The {@link HttpConnectionManager} in the {@link Listener} must have either, | ||
* {@link HttpConnectionManager#hasRds()} or {@link HttpConnectionManager#hasRouteConfig()}. |
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 the tree are updated. The {@link HttpConnectionManager} in the {@link Listener} must have either, | |
* {@link HttpConnectionManager#hasRds()} or {@link HttpConnectionManager#hasRouteConfig()}. | |
* in the tree are updated. |
Technically, it is perfectly valid to have a Listener
without a Route
attached to it
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.
Technically, it is perfectly valid to have a Listener without a Route attached to it
Yes, but we cannot use the listener without a Route attached to it and
it raises an exception if it doesn't have it.
checkArgument(connectionManager.hasRds() || connectionManager.hasRouteConfig(), |
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.
Left a minor question but looks good to me! 👍 Thanks @minwoox 🙇 👍 🙇
final StaticResources staticResources = bootstrap.getStaticResources(); | ||
for (Listener listener: staticResources.getListenersList()) { | ||
final ListenerXdsResource listenerResource = ListenerResourceParser.INSTANCE.parse(listener); | ||
builder.put(listener.getName(), listenerResource); |
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.
note: envoy seems to generate a random name if not present.
I don't think this is an issue for now, but might be something to consider in case anyone files an issue.
xds/src/main/java/com/linecorp/armeria/xds/XdsEndpointGroup.java
Outdated
Show resolved
Hide resolved
xds/src/main/java/com/linecorp/armeria/xds/XdsConverterUtil.java
Outdated
Show resolved
Hide resolved
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!
xds/src/main/java/com/linecorp/armeria/xds/BootstrapListeners.java
Outdated
Show resolved
Hide resolved
xds/src/main/java/com/linecorp/armeria/xds/XdsConverterUtil.java
Outdated
Show resolved
Hide resolved
Let me merge this and send another PR for Mostly static with dynamic EDS. |
…tadata in XdsEndpointGroup. (line#5461) Motivation: Envoy allows configuring subsets for an upstream cluster using metadata. Subsets are defined based on metadata associated with each endpoint, and configurations within `lb_subset_config` and `metadata_match` in the `Cluster` and `RouteConfiguration` respectively. This enhancement ensures compatibility with Envoy's subset configuration capabilities, facilitating more granular load balancing. [Load Balancer Subsets](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/load_balancing/subsets) Modifications: - Introduce functionality in `XdsEndpointGroup` to divide an upstream cluster into subsets based on metadata. - Add `XdsBootstrap.listenerRoot(Listener)` to create a listener root with a static listener resource. Result: - You can now divide an upstream cluster into subsets effectively within `XdsEndpointGroup`, enabling more sophisticated load balancing configurations.
Motivation:
Envoy allows configuring subsets for an upstream cluster using metadata. Subsets are defined based on metadata associated with each endpoint, and configurations within
lb_subset_config
andmetadata_match
in theCluster
andRouteConfiguration
respectively. This enhancement ensures compatibility with Envoy's subset configuration capabilities, facilitating more granular load balancing. Load Balancer SubsetsModifications:
XdsEndpointGroup
to divide an upstream cluster into subsets based on metadata.XdsBootstrap.listenerRoot(Listener)
to create a listener root with a static listener resource.Result:
XdsEndpointGroup
, enabling more sophisticated load balancing configurations.