Skip to content

Commit

Permalink
More progress
Browse files Browse the repository at this point in the history
  • Loading branch information
larry-safran committed Feb 22, 2025
1 parent 67ea1a2 commit eed440e
Show file tree
Hide file tree
Showing 3 changed files with 254 additions and 80 deletions.
8 changes: 8 additions & 0 deletions xds/src/main/java/io/grpc/xds/CdsLoadBalancer2.java
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ public Status acceptResolvedAddresses(ResolvedAddresses resolvedAddresses) {
String rootClusterName = ((CdsConfig) resolvedAddresses.getLoadBalancingPolicyConfig()).name;
XdsConfig xdsConfig = resolvedAddresses.getAttributes().get(XdsAttributes.XDS_CONFIG);

if (xdsConfig.getClusters().get(rootClusterName) == null) {
return Status.UNAVAILABLE.withDescription(
"CDS resource not found for root cluster: " + rootClusterName);
}

logger.log(XdsLogLevel.DEBUG, "Received resolution result: {0}", resolvedAddresses);
this.resolvedAddresses = resolvedAddresses;
rootCdsLbState =
Expand Down Expand Up @@ -1046,6 +1051,9 @@ private void shutdown() {
// If doesn't have children is a no-op
private void initializeChildren(ImmutableMap<String,
StatusOr<XdsConfig.XdsClusterConfig>> clusterConfigs, ClusterStateDetails curRoot) {
if (curRoot.result == null) {
return;
}
ImmutableList<String> childNames = curRoot.result.prioritizedClusterNames();
if (childNames == null) {
return;
Expand Down
15 changes: 13 additions & 2 deletions xds/src/main/java/io/grpc/xds/XdsDependencyManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -579,6 +579,12 @@ public void onChanged(XdsClusterResource.CdsUpdate update) {
switch (update.clusterType()) {
case EDS:
setData(update);
if (update.edsServiceName() == null) {
Status error = Status.UNAVAILABLE.withDescription("EDS cluster missing edsServiceName");
setDataAsStatus(error);
maybePublishConfig();
return;
}
if (!addEdsWatcher(update.edsServiceName(), this)) {
maybePublishConfig();
}
Expand All @@ -599,8 +605,13 @@ public void onChanged(XdsClusterResource.CdsUpdate update) {
setDataAsStatus(error);
}
if (hasDataValue()) {
Set<String> oldNames = new HashSet<>(getData().getValue().prioritizedClusterNames());
Set<String> newNames = new HashSet<>(update.prioritizedClusterNames());
ImmutableList<String> oldChildNames = getData().getValue().prioritizedClusterNames();
Set<String> oldNames = oldChildNames != null
? new HashSet<>(oldChildNames)
: new HashSet<>();
ImmutableList<String> newChildNames = update.prioritizedClusterNames();
Set<String> newNames =
newChildNames != null ? new HashSet<>(newChildNames) : new HashSet<>();


Set<String> deletedClusters = Sets.difference(oldNames, newNames);
Expand Down
Loading

0 comments on commit eed440e

Please sign in to comment.