Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
ed5072e
Add Docker fiels for xds example server and client.
kannanjgithub May 20, 2025
c8be933
Merge branch 'grpc:master' into master
kannanjgithub Jun 3, 2025
63997fd
Merge branch 'grpc:master' into master
kannanjgithub Jun 6, 2025
5140beb
Merge branch 'grpc:master' into master
kannanjgithub Jun 11, 2025
029db63
Merge branch 'grpc:master' into master
kannanjgithub Jun 13, 2025
f472436
Merge branch 'grpc:master' into master
kannanjgithub Jun 23, 2025
459208c
in-progress changes.
kannanjgithub Jun 23, 2025
6cddc61
in-progress changes.
kannanjgithub Jun 24, 2025
f038f4c
in-progress changes.
kannanjgithub Jun 25, 2025
ad9b1b3
in-progress changes.
kannanjgithub Jun 25, 2025
d92902d
in-progress changes.
kannanjgithub Jun 26, 2025
60fae37
in-progress changes.
kannanjgithub Jun 26, 2025
6f0a920
Revert "Add Docker fiels for xds example server and client."
kannanjgithub Jun 26, 2025
d816b8e
Changes
kannanjgithub Jun 27, 2025
c8eca59
whitespace changes nightmares
kannanjgithub Jun 27, 2025
4b92066
whitespace changes nightmares
kannanjgithub Jun 27, 2025
3867cc7
whitespace changes nightmares
kannanjgithub Jun 27, 2025
c4bfaa5
Replace clusters array with single cluster in ClusterResolverLB
kannanjgithub Jun 30, 2025
400b776
Review comments, excepting the child cluster type change handling.
kannanjgithub Jul 9, 2025
fa21404
nit
kannanjgithub Jul 9, 2025
084c51c
Handle cluster type changes by using Graceful switch load balancer as…
kannanjgithub Jul 11, 2025
f2bfa63
Fix test
kannanjgithub Jul 11, 2025
7abbc4a
Review comments.
kannanjgithub Jul 18, 2025
7c16de8
Revert indendation changes done by IDE in unchanged lines.
kannanjgithub Jul 18, 2025
f6afb63
A map for ClusterState is not required in ClusterResolverLoadBalancer…
kannanjgithub Jul 22, 2025
e2a7382
Reinstantiate delegate after shutdown.
kannanjgithub Jul 29, 2025
ecb6b03
Merge branch 'master' into a75-fixes2
kannanjgithub Jul 29, 2025
8c1199d
Fix problem after merge.
kannanjgithub Jul 29, 2025
24910d8
Fix problem after merge.
kannanjgithub Jul 29, 2025
6c75018
Fix style errors.
kannanjgithub Jul 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Review comments, excepting the child cluster type change handling.
  • Loading branch information
kannanjgithub committed Jul 9, 2025
commit 400b77642daee19ae80d79cb4c2c60eb5436bdd6
16 changes: 6 additions & 10 deletions xds/src/main/java/io/grpc/xds/CdsLoadBalancer2.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,10 @@
import static io.grpc.xds.XdsLbPolicies.CDS_POLICY_NAME;
import static io.grpc.xds.XdsLbPolicies.CLUSTER_RESOLVER_POLICY_NAME;
import static io.grpc.xds.XdsLbPolicies.PRIORITY_POLICY_NAME;
import static java.util.Objects.requireNonNull;

import com.google.errorprone.annotations.CheckReturnValue;
import io.grpc.InternalLogId;
import io.grpc.LoadBalancer;
import io.grpc.LoadBalancerProvider;
import io.grpc.LoadBalancerRegistry;
import io.grpc.NameResolver;
import io.grpc.Status;
Expand All @@ -47,6 +45,7 @@
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
Expand All @@ -65,7 +64,7 @@ final class CdsLoadBalancer2 extends LoadBalancer {

CdsLoadBalancer2(Helper helper, LoadBalancerRegistry lbRegistry) {
this.helper = checkNotNull(helper, "helper");
this.lbRegistry = lbRegistry;
this.lbRegistry = checkNotNull(lbRegistry, "lbRegistry");
logger = XdsLogger.withLogId(InternalLogId.allocate("cds-lb", helper.getAuthority()));
logger.log(XdsLogLevel.INFO, "Created");
}
Expand Down Expand Up @@ -140,13 +139,12 @@ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
childLb = lbRegistry.getProvider(CLUSTER_RESOLVER_POLICY_NAME).newLoadBalancer(helper);
}
} else if (clusterConfig.getChildren() instanceof AggregateConfig) {
LoadBalancerProvider priorityLbProvider = lbRegistry.getProvider(PRIORITY_POLICY_NAME);
if (childLb == null) {
childLb = priorityLbProvider.newLoadBalancer(helper);
childLb = lbRegistry.getProvider(PRIORITY_POLICY_NAME).newLoadBalancer(helper);
}
Map<String, PriorityChildConfig> priorityChildConfigs = new HashMap<>();
for (String childCluster: requireNonNull(
clusterConfig.getClusterResource().prioritizedClusterNames())) {
List<String> leafClusters = ((AggregateConfig) clusterConfig.getChildren()).getLeafNames();
for (String childCluster: leafClusters) {
priorityChildConfigs.put(childCluster,
new PriorityChildConfig(
GracefulSwitchLoadBalancer.createLoadBalancingPolicyConfig(
Expand All @@ -155,9 +153,7 @@ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
false));
}
childConfig = new PriorityLoadBalancerProvider.PriorityLbConfig(
Collections.unmodifiableMap(priorityChildConfigs),
Collections.unmodifiableList(requireNonNull(
clusterConfig.getClusterResource().prioritizedClusterNames())));
Collections.unmodifiableMap(priorityChildConfigs), leafClusters);
} else {
return fail(Status.INTERNAL.withDescription(
errorPrefix() + "Unexpected cluster children type: "
Expand Down
77 changes: 58 additions & 19 deletions xds/src/test/java/io/grpc/xds/CdsLoadBalancer2Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -414,19 +414,51 @@ public void discoverAggregateCluster_createsPriorityLbPolicy() {

String cluster1 = "cluster-01.googleapis.com";
String cluster2 = "cluster-02.googleapis.com";
String cluster3 = "cluster-03.googleapis.com";
String cluster4 = "cluster-04.googleapis.com";
controlPlaneService.setXdsConfig(ADS_TYPE_URL_CDS, ImmutableMap.of(
// CLUSTER (aggr.) -> [cluster1 (EDS), cluster2 (EDS)]
// CLUSTER (aggr.) -> [cluster1 (aggr.), cluster2 (logical DNS), cluster3 (EDS)]
CLUSTER, Cluster.newBuilder()
.setName(CLUSTER)
Comment thread
ejona86 marked this conversation as resolved.
.setClusterType(Cluster.CustomClusterType.newBuilder()
.setName("envoy.clusters.aggregate")
.setTypedConfig(Any.pack(ClusterConfig.newBuilder()
.addClusters(cluster1)
.addClusters(cluster2)
.build())))
.build(),
cluster1, EDS_CLUSTER.toBuilder().setName(cluster1).build(),
cluster2, EDS_CLUSTER.toBuilder().setName(cluster2).build()));
.setName(CLUSTER)
.setClusterType(Cluster.CustomClusterType.newBuilder()
.setName("envoy.clusters.aggregate")
.setTypedConfig(Any.pack(ClusterConfig.newBuilder()
.addClusters(cluster1)
.addClusters(cluster2)
.addClusters(cluster3)
.build())))
.setLbPolicy(Cluster.LbPolicy.RING_HASH)
.build(),
// cluster1 (aggr.) -> [cluster3 (EDS), cluster4 (EDS)]
cluster1, Cluster.newBuilder()
.setName(cluster1)
.setClusterType(Cluster.CustomClusterType.newBuilder()
.setName("envoy.clusters.aggregate")
.setTypedConfig(Any.pack(ClusterConfig.newBuilder()
.addClusters(cluster3)
.addClusters(cluster4)
.build())))
.build(),
cluster2, Cluster.newBuilder()
.setName(cluster2)
.setType(Cluster.DiscoveryType.LOGICAL_DNS)
.setLoadAssignment(ClusterLoadAssignment.newBuilder()
.addEndpoints(LocalityLbEndpoints.newBuilder()
.addLbEndpoints(LbEndpoint.newBuilder()
.setEndpoint(Endpoint.newBuilder()
.setAddress(Address.newBuilder()
.setSocketAddress(SocketAddress.newBuilder()
.setAddress("dns.example.com")
.setPortValue(1111)))))))
.build(),
cluster3, EDS_CLUSTER.toBuilder()
.setName(cluster3)
.setCircuitBreakers(CircuitBreakers.newBuilder()
.addThresholds(CircuitBreakers.Thresholds.newBuilder()
.setPriority(RoutingPriority.DEFAULT)
.setMaxRequests(UInt32Value.newBuilder().setValue(100))))
.build(),
cluster4, EDS_CLUSTER.toBuilder().setName(cluster4).build()));
startXdsDepManager();

verify(helper, never()).updateBalancingState(eq(ConnectivityState.TRANSIENT_FAILURE), any());
Expand All @@ -435,16 +467,23 @@ public void discoverAggregateCluster_createsPriorityLbPolicy() {
assertThat(childBalancer.name).isEqualTo(PRIORITY_POLICY_NAME);
PriorityLoadBalancerProvider.PriorityLbConfig childLbConfig =
(PriorityLoadBalancerProvider.PriorityLbConfig) childBalancer.config;
assertThat(childLbConfig.priorities).hasSize(2);
assertThat(childLbConfig.priorities.get(0)).isEqualTo(cluster1);
assertThat(childLbConfig.priorities.get(1)).isEqualTo(cluster2);
assertThat(childLbConfig.childConfigs).hasSize(2);
PriorityLoadBalancerProvider.PriorityLbConfig.PriorityChildConfig childConfig1 =
childLbConfig.childConfigs.get(cluster1);
assertThat(childConfig1.toString()).isEqualTo("PriorityChildConfig{childConfig="
assertThat(childLbConfig.priorities).hasSize(3);
assertThat(childLbConfig.priorities.get(0)).isEqualTo(cluster3);
assertThat(childLbConfig.priorities.get(1)).isEqualTo(cluster4);
assertThat(childLbConfig.priorities.get(2)).isEqualTo(cluster2);
assertThat(childLbConfig.childConfigs).hasSize(3);
PriorityLoadBalancerProvider.PriorityLbConfig.PriorityChildConfig childConfig3 =
childLbConfig.childConfigs.get(cluster3);
assertThat(childConfig3.toString()).isEqualTo("PriorityChildConfig{childConfig="
Comment thread
ejona86 marked this conversation as resolved.
Outdated
+ "GracefulSwitchLoadBalancer.Config{childFactory=CdsLoadBalancerProvider{"
+ "policy=cds_experimental, priority=5, available=true}, childConfig=CdsConfig{"
+ "name=cluster-03.googleapis.com, isDynamic=false}}, ignoreReresolution=false}");
PriorityLoadBalancerProvider.PriorityLbConfig.PriorityChildConfig childConfig4 =
childLbConfig.childConfigs.get(cluster4);
assertThat(childConfig4.toString()).isEqualTo("PriorityChildConfig{childConfig="
+ "GracefulSwitchLoadBalancer.Config{childFactory=CdsLoadBalancerProvider{"
+ "policy=cds_experimental, priority=5, available=true}, childConfig=CdsConfig{"
+ "name=cluster-01.googleapis.com, isDynamic=false}}, ignoreReresolution=false}");
+ "name=cluster-04.googleapis.com, isDynamic=false}}, ignoreReresolution=false}");
PriorityLoadBalancerProvider.PriorityLbConfig.PriorityChildConfig childConfig2 =
childLbConfig.childConfigs.get(cluster2);
assertThat(childConfig2.toString()).isEqualTo("PriorityChildConfig{childConfig="
Expand Down