xds: Move backend service label plumbing to CDS#12882
Conversation
A75 changed aggregate cluster handling so aggregate clusters are represented as priority children whose children are CDS policies. In that structure, A89 expects backend service metric plumbing to go through CDS instead of xds_cluster_impl. Set NameResolver.ATTR_BACKEND_SERVICE from CdsLoadBalancer2 for non-aggregate leaf clusters so WRR metrics can read the backend service. Also add the grpc.lb.backend_service pick details label from the leaf CDS picker wrapper. Do not add the aggregate root cluster as backend_service. Remove the old backend_service attribute and pick details label handling from ClusterImplLoadBalancer.
|
|
||
| @Test | ||
| // Both priorities will get tried using real priority LB policy. | ||
| public void discoverAggregateCluster_testChildCdsLbPolicyParsing() { |
There was a problem hiding this comment.
Can you also test triggering a subchannel pick using a mock PickDetailsConsumer for the aggregate cluster and verify that the leaf instance actually adds the rpc.lb.backend_service label during a pick?
There was a problem hiding this comment.
Thanks for the review.
Done. I added a test that uses the real priority policy to instantiate the leaf CDS path under an aggregate cluster, then triggers a pick through the top-level picker with a mock PickDetailsConsumer.
The test verifies that grpc.lb.backend_service is added with the leaf cluster name and not the aggregate root cluster name.
I also renamed the aggregate-root negative test from "Or" to "And" since it checks both the backend service attribute and the pick-details label.
There was a problem hiding this comment.
Pull request overview
This PR moves backend service metric label plumbing from xds_cluster_impl to cds so that aggregate clusters use the correct leaf CDS cluster name (per A75/A89 behavior), and removes the now-incorrect plumbing from xds_cluster_impl.
Changes:
CdsLoadBalancer2now (for non-aggregate clusters) propagatesNameResolver.ATTR_BACKEND_SERVICEdownstream and injects the per-RPC pick-details labelgrpc.lb.backend_serviceusing the CDS cluster name; aggregate-root CDS explicitly does not inject these.ClusterImplLoadBalancerno longer setsNameResolver.ATTR_BACKEND_SERVICEfor its child policy and no longer adds thegrpc.lb.backend_servicepick-details label.- Tests are updated to validate the new propagation/labeling behavior and to use a non-null
PickDetailsConsumerin picker invocations (matching thePickSubchannelArgscontract).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| xds/src/test/java/io/grpc/xds/ClusterResolverLoadBalancerTest.java | Updates picker test helper to provide a non-null PickDetailsConsumer. |
| xds/src/test/java/io/grpc/xds/ClusterImplLoadBalancerTest.java | Adjusts assertions to confirm xds_cluster_impl no longer propagates backend service attributes or pick-details labels. |
| xds/src/test/java/io/grpc/xds/CdsLoadBalancer2Test.java | Adds/updates tests for non-aggregate vs aggregate-root behavior and ensures picker args include a non-null PickDetailsConsumer. |
| xds/src/main/java/io/grpc/xds/ClusterImplLoadBalancer.java | Removes backend service attribute propagation and pick-details label injection from xds_cluster_impl. |
| xds/src/main/java/io/grpc/xds/CdsLoadBalancer2.java | Adds backend service attribute propagation and pick-details label injection at the CDS layer, with aggregate-root disabling. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Add coverage for the aggregate cluster path to verify that a pick through the aggregate LB stack adds grpc.lb.backend_service from the leaf CDS instance, not from the aggregate root. Also rename the aggregate-root negative test to use "And" because it checks both the backend service attribute and pick-details label.
Addresses #12431.
This moves backend service metric label plumbing from
xds_cluster_impltocds, matching the A75/A89 aggregate cluster behavior.Previously,
xds_cluster_impladded thegrpc.lb.backend_servicepick-details label and propagatedNameResolver.ATTR_BACKEND_SERVICEto its child policy. That works for simple clusters, but it is the wrong layer after A75 because aggregate clusters need the leaf CDS cluster name, not the aggregate root cluster name.This change makes CDS responsible for backend service plumbing:
grpc.lb.backend_servicepick-details label using the CDS cluster nameNameResolver.ATTR_BACKEND_SERVICEto its child policy, so WRR can consume the backend service contextxds_cluster_implno longer owns backend service pick-details label or child attribute propagationThe existing
InternalEquivalentAddressGroup.ATTR_BACKEND_SERVICEpath is left unchanged for endpoint/subchannel metrics.Tests cover:
NameResolver.ATTR_BACKEND_SERVICEgrpc.lb.backend_servicexds_cluster_implno longer adding backend service labels or attributesPickDetailsConsumer, matching the realPickSubchannelArgscontract