Skip to content

Commit 4ba6de4

Browse files
committed
address comments
1 parent 3779aea commit 4ba6de4

2 files changed

Lines changed: 12 additions & 9 deletions

File tree

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,13 @@ public interface ResourceUpdate {}
140140

141141
/**
142142
* Watcher interface for a single requested xDS resource.
143+
*
144+
* <p>Note that we expect that the implementer to:
145+
* - Comply with the guarantee to not generate certain statuses by the library:
146+
* https://grpc.github.io/grpc/core/md_doc_statuscodes.html. If the code needs to be
147+
* propagated to the channel, override it with {@link io.grpc.Status.Code#UNAVAILABLE}.
148+
* - Keep {@link Status} description in one form or another, as it contains valuable debugging
149+
* information.
143150
*/
144151
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/10862")
145152
public interface ResourceWatcher<T extends ResourceUpdate> {

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

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,6 @@ public void run() {
293293
private <T extends ResourceUpdate> CpcWithFallbackState manageControlPlaneClient(
294294
ResourceSubscriber<T> subscriber) {
295295

296-
ControlPlaneClient activeCpc = getActiveCpc(subscriber.authority);
297296
ControlPlaneClient cpcToUse;
298297
boolean didFallback = false;
299298
try {
@@ -313,16 +312,17 @@ private <T extends ResourceUpdate> CpcWithFallbackState manageControlPlaneClient
313312
return new CpcWithFallbackState(null, false);
314313
}
315314

316-
if (cpcToUse != activeCpc) {
315+
ControlPlaneClient activeCpClient = getActiveCpc(subscriber.authority);
316+
if (cpcToUse != activeCpClient) {
317317
addCpcToAuthority(subscriber.authority, cpcToUse);
318-
if (activeCpc != null) {
318+
if (activeCpClient != null) {
319319
didFallback = cpcToUse != null && !cpcToUse.isInError();
320320
if (didFallback) {
321321
logger.log(XdsLogLevel.INFO, "Falling back to XDS server {0}",
322322
cpcToUse.getServerInfo().target());
323323
} else {
324324
logger.log(XdsLogLevel.WARNING, "No working fallback XDS Servers found from {0}",
325-
activeCpc.getServerInfo().target());
325+
activeCpClient.getServerInfo().target());
326326
}
327327
}
328328
}
@@ -847,7 +847,7 @@ void onData(ParsedResource<T> parsedResource, String version, long updateTime,
847847
processingTracker.startTask();
848848
executor.execute(() -> {
849849
try {
850-
watcher.onResourceChanged(update); // Call the new method
850+
watcher.onResourceChanged(update);
851851
} finally {
852852
processingTracker.onComplete();
853853
}
@@ -1033,10 +1033,6 @@ public void handleStreamClosed(Status status, boolean shouldTryFallback) {
10331033
if (!authoritiesForClosedCpc.contains(subscriber.authority)) {
10341034
continue;
10351035
}
1036-
if (subscriber.hasResult()) {
1037-
subscriber.onError(status, null); // This will become an onAmbientError
1038-
continue;
1039-
}
10401036

10411037
// try to fallback to lower priority control plane client
10421038
if (shouldTryFallback && manageControlPlaneClient(subscriber).didFallback) {

0 commit comments

Comments
 (0)