Skip to content

Commit 037cdef

Browse files
committed
fix empty resource subscription
1 parent 133de5e commit 037cdef

2 files changed

Lines changed: 4 additions & 4 deletions

File tree

xds/src/main/java/io/grpc/xds/client/ControlPlaneClient.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -152,9 +152,7 @@ void adjustResourceSubscription(XdsResourceType<?> resourceType) {
152152
startRpcStream();
153153
}
154154
Collection<String> resources = resourceStore.getSubscribedResources(serverInfo, resourceType);
155-
if (resources != null) {
156-
adsStream.sendDiscoveryRequest(resourceType, resources);
157-
}
155+
adsStream.sendDiscoveryRequest(resourceType, resources == null ? Collections.emptySet() : resources);
158156
}
159157

160158
/**

xds/src/test/java/io/grpc/xds/GrpcXdsClientImplTestBase.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2783,13 +2783,15 @@ public void edsAllowRespondAfterUnsubscription() {
27832783
// 1) the EDS unsubscription caused by CDS PUSH e1 (client-side) and,
27842784
// 2) the immediate EDS PUSH from XdsServer (server-side) after CDS PUSH e1 (event e2).
27852785
xdsClient.cancelXdsResourceWatch(XdsEndpointResource.getInstance(), "A.1", edsResourceWatcher);
2786+
// FIX(1): allow to send empty subscription
2787+
call.verifyRequest(EDS, Collections.emptyList(), VERSION_1, "0000", NODE);
27862788
verifySubscribedResourcesMetadataSizes(0, 0, 0, 0);
27872789
// An EDS PUSH after CDS PUSH e1.
27882790
List<Message> endpointsV2 = ImmutableList.of(lbEndpointHealthy);
27892791
ImmutableMap<String, Any> resourcesV2 = ImmutableMap.of(
27902792
"A.1", Any.pack(mf.buildClusterLoadAssignment("A.1", endpointsV2, dropOverloads)));
27912793
call.sendResponse(EDS, resourcesV2.values().asList(), VERSION_2, "0001");
2792-
// This will send an empty resource list to the XdsServer
2794+
// FIX(2): allow to update resource version even if the subscription resource is empty
27932795
call.verifyRequest(EDS, Collections.emptyList(), VERSION_2, "0001", NODE);
27942796
verifyNoMoreInteractions(edsResourceWatcher);
27952797
}

0 commit comments

Comments
 (0)