xds: Non-SOTW resources need onError() callbacks, too (#12122)

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.
This commit is contained in:
Eric Anderson 2025-06-02 23:32:02 -07:00 committed by GitHub
parent 48d08e643e
commit efe9ccc22c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 6 deletions

View File

@ -592,12 +592,6 @@ public final class XdsClientImpl extends XdsClient implements ResourceStore {
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 @@ public final class XdsClientImpl extends XdsClient implements ResourceStore {
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.

View File

@ -3270,6 +3270,8 @@ public abstract class GrpcXdsClientImplTestBase {
+ "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