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

Fix to support for dividing an upstream cluster into subsets using metadata in XdsEndpointGroup. #5461

Merged
merged 6 commits into from Feb 16, 2024

Conversation

minwoox
Copy link
Member

@minwoox minwoox commented Feb 14, 2024

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

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.

…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.
@minwoox minwoox added the defect label Feb 14, 2024
@minwoox minwoox added this to the 1.27.2 milestone Feb 14, 2024
Copy link
Contributor

@jrhee17 jrhee17 left a 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 👍

return;
}
final LbSubsetFallbackPolicy fallbackPolicy = lbSubsetConfig.getFallbackPolicy();
if (fallbackPolicy != LbSubsetFallbackPolicy.ANY_ENDPOINT) {
Copy link
Contributor

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.

Copy link
Member Author

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. 😉

@jrhee17
Copy link
Contributor

jrhee17 commented Feb 14, 2024

One more question (although not directly related to this PR)

I understood that certain projects may need to customize metadata_match and lb_subset_config. I'm curious how we will allow users to configure their own projects (since CD based xDS doesn't support modifying xDS configurations by end-users yet)

Comment on lines 75 to 76
* in the tree are updated. The {@link HttpConnectionManager} in the {@link Listener} must have either,
* {@link HttpConnectionManager#hasRds()} or {@link HttpConnectionManager#hasRouteConfig()}.
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
* 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

Copy link
Member Author

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(),

Copy link
Contributor

@jrhee17 jrhee17 left a 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);
Copy link
Contributor

@jrhee17 jrhee17 Feb 14, 2024

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.

ref: https://github.com/envoyproxy/envoy/blob/45b3f9af9d3889f23b4aded7416d92687cc72de0/source/common/listener_manager/listener_manager_impl.cc#L458

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.

Looks good!

@minwoox
Copy link
Member Author

minwoox commented Feb 16, 2024

Let me merge this and send another PR for Mostly static with dynamic EDS.
Thanks a lot for reviewing. 🙇

@minwoox minwoox merged commit 7d2ab64 into line:main Feb 16, 2024
15 of 16 checks passed
@minwoox minwoox deleted the add_subsetting branch February 16, 2024 02:11
jrhee17 pushed a commit to jrhee17/armeria that referenced this pull request Mar 4, 2024
…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants