From d4f43f249c7ae0a7a91286c5847222758abafa5a Mon Sep 17 00:00:00 2001 From: Eric Anderson Date: Sun, 1 Jun 2025 14:27:08 -0700 Subject: [PATCH] xds: Non-SOTW resources need onError() callbacks, too SOTW is unique in that it can become absent after being found. But if we NACK when initially loading the resource, we don't want to delay, depend on the resource timeout, and then give a poor error. This was noticed while adding the EDS restriction that address is not a hostname and some tests started hanging instead of failing quickly. --- .../main/java/io/grpc/xds/client/XdsClientImpl.java | 11 +++++------ .../java/io/grpc/xds/GrpcXdsClientImplTestBase.java | 2 ++ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/xds/src/main/java/io/grpc/xds/client/XdsClientImpl.java b/xds/src/main/java/io/grpc/xds/client/XdsClientImpl.java index 4de8ead7c0a..2b25d4db977 100644 --- a/xds/src/main/java/io/grpc/xds/client/XdsClientImpl.java +++ b/xds/src/main/java/io/grpc/xds/client/XdsClientImpl.java @@ -592,12 +592,6 @@ private void handleResourceUpdate( subscriber.onRejected(args.versionInfo, updateTime, errorDetail); } - // Nothing else to do for incremental ADS resources. - if (!xdsResourceType.isFullStateOfTheWorld()) { - continue; - } - - // Handle State of the World ADS: invalid resources. if (invalidResources.contains(resourceName)) { // The resource is missing. Reuse the cached resource if possible. if (subscriber.data == null) { @@ -607,6 +601,11 @@ private void handleResourceUpdate( continue; } + // Nothing else to do for incremental ADS resources. + if (!xdsResourceType.isFullStateOfTheWorld()) { + continue; + } + // For State of the World services, notify watchers when their watched resource is missing // from the ADS update. Note that we can only do this if the resource update is coming from // the same xDS server that the ResourceSubscriber is subscribed to. diff --git a/xds/src/test/java/io/grpc/xds/GrpcXdsClientImplTestBase.java b/xds/src/test/java/io/grpc/xds/GrpcXdsClientImplTestBase.java index 369763a21b7..006440be6c1 100644 --- a/xds/src/test/java/io/grpc/xds/GrpcXdsClientImplTestBase.java +++ b/xds/src/test/java/io/grpc/xds/GrpcXdsClientImplTestBase.java @@ -3270,6 +3270,8 @@ public void edsDuplicateLocalityInTheSamePriority() { + "locality:Locality{region=region2, zone=zone2, subZone=subzone2} for priority:1"; call.verifyRequestNack(EDS, EDS_RESOURCE, "", "0001", NODE, ImmutableList.of( errorMsg)); + verify(edsResourceWatcher).onError(errorCaptor.capture()); + assertThat(errorCaptor.getValue().getDescription()).contains(errorMsg); } @Test