mirror of https://github.com/grpc/grpc-java.git
xds: fix bug of concluding retry state without checking retry task status (#6519)
This commit is contained in:
parent
f6544bf95c
commit
d007af18e6
|
|
@ -181,7 +181,7 @@ final class XdsClientImpl extends XdsClient {
|
||||||
} else {
|
} else {
|
||||||
ldsResourceName = hostName + ":" + port;
|
ldsResourceName = hostName + ":" + port;
|
||||||
}
|
}
|
||||||
if (rpcRetryTimer != null) {
|
if (rpcRetryTimer != null && rpcRetryTimer.isPending()) {
|
||||||
// Currently in retry backoff.
|
// Currently in retry backoff.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -210,7 +210,7 @@ final class XdsClientImpl extends XdsClient {
|
||||||
if (clusterNamesToClusterUpdates.containsKey(clusterName)) {
|
if (clusterNamesToClusterUpdates.containsKey(clusterName)) {
|
||||||
watcher.onClusterChanged(clusterNamesToClusterUpdates.get(clusterName));
|
watcher.onClusterChanged(clusterNamesToClusterUpdates.get(clusterName));
|
||||||
}
|
}
|
||||||
if (rpcRetryTimer != null) {
|
if (rpcRetryTimer != null && rpcRetryTimer.isPending()) {
|
||||||
// Currently in retry backoff.
|
// Currently in retry backoff.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -241,7 +241,7 @@ final class XdsClientImpl extends XdsClient {
|
||||||
}
|
}
|
||||||
// No longer interested in this cluster, send an updated CDS request to unsubscribe
|
// No longer interested in this cluster, send an updated CDS request to unsubscribe
|
||||||
// this resource.
|
// this resource.
|
||||||
if (rpcRetryTimer != null) {
|
if (rpcRetryTimer != null && rpcRetryTimer.isPending()) {
|
||||||
// Currently in retry backoff.
|
// Currently in retry backoff.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -271,7 +271,7 @@ final class XdsClientImpl extends XdsClient {
|
||||||
if (clusterNamesToEndpointUpdates.containsKey(clusterName)) {
|
if (clusterNamesToEndpointUpdates.containsKey(clusterName)) {
|
||||||
watcher.onEndpointChanged(clusterNamesToEndpointUpdates.get(clusterName));
|
watcher.onEndpointChanged(clusterNamesToEndpointUpdates.get(clusterName));
|
||||||
}
|
}
|
||||||
if (rpcRetryTimer != null) {
|
if (rpcRetryTimer != null && rpcRetryTimer.isPending()) {
|
||||||
// Currently in retry backoff.
|
// Currently in retry backoff.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -299,7 +299,7 @@ final class XdsClientImpl extends XdsClient {
|
||||||
clusterNamesToEndpointUpdates.remove(clusterName);
|
clusterNamesToEndpointUpdates.remove(clusterName);
|
||||||
// No longer interested in this cluster, send an updated EDS request to unsubscribe
|
// No longer interested in this cluster, send an updated EDS request to unsubscribe
|
||||||
// this resource.
|
// this resource.
|
||||||
if (rpcRetryTimer != null) {
|
if (rpcRetryTimer != null && rpcRetryTimer.isPending()) {
|
||||||
// Currently in retry backoff.
|
// Currently in retry backoff.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2543,6 +2543,20 @@ public class XdsClientImplTest {
|
||||||
|
|
||||||
// Client sent an CDS ACK request (Omitted).
|
// Client sent an CDS ACK request (Omitted).
|
||||||
|
|
||||||
|
// No longer interested in endpoint information after RPC resumes.
|
||||||
|
xdsClient.cancelEndpointDataWatch("cluster.googleapis.com", endpointWatcher);
|
||||||
|
// Client updates EDS resource subscription immediately.
|
||||||
|
verify(requestObserver)
|
||||||
|
.onNext(eq(buildDiscoveryRequest(NODE, "", ImmutableList.<String>of(),
|
||||||
|
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||||
|
|
||||||
|
// Become interested in endpoints of another cluster.
|
||||||
|
xdsClient.watchEndpointData("cluster2.googleapis.com", endpointWatcher);
|
||||||
|
// Client updates EDS resource subscription immediately.
|
||||||
|
verify(requestObserver)
|
||||||
|
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster2.googleapis.com",
|
||||||
|
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||||
|
|
||||||
// Management server closes the RPC stream again.
|
// Management server closes the RPC stream again.
|
||||||
responseObserver.onCompleted();
|
responseObserver.onCompleted();
|
||||||
|
|
||||||
|
|
@ -2560,7 +2574,7 @@ public class XdsClientImplTest {
|
||||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||||
verify(requestObserver)
|
verify(requestObserver)
|
||||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster2.googleapis.com",
|
||||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||||
|
|
||||||
// Management server becomes unreachable again.
|
// Management server becomes unreachable again.
|
||||||
|
|
@ -2570,7 +2584,7 @@ public class XdsClientImplTest {
|
||||||
|
|
||||||
// No longer interested in previous cluster and endpoints in that cluster.
|
// No longer interested in previous cluster and endpoints in that cluster.
|
||||||
xdsClient.cancelClusterDataWatch("cluster.googleapis.com", clusterWatcher);
|
xdsClient.cancelClusterDataWatch("cluster.googleapis.com", clusterWatcher);
|
||||||
xdsClient.cancelEndpointDataWatch("cluster.googleapis.com", endpointWatcher);
|
xdsClient.cancelEndpointDataWatch("cluster2.googleapis.com", endpointWatcher);
|
||||||
|
|
||||||
// Retry after backoff.
|
// Retry after backoff.
|
||||||
fakeClock.forwardNanos(19L);
|
fakeClock.forwardNanos(19L);
|
||||||
|
|
@ -2587,7 +2601,7 @@ public class XdsClientImplTest {
|
||||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
||||||
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
XdsClientImpl.ADS_TYPE_URL_CDS, "")));
|
||||||
verify(requestObserver, never())
|
verify(requestObserver, never())
|
||||||
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster.googleapis.com",
|
.onNext(eq(buildDiscoveryRequest(NODE, "", "cluster2.googleapis.com",
|
||||||
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
XdsClientImpl.ADS_TYPE_URL_EDS, "")));
|
||||||
|
|
||||||
verifyNoMoreInteractions(mockedDiscoveryService, backoffPolicyProvider, backoffPolicy1,
|
verifyNoMoreInteractions(mockedDiscoveryService, backoffPolicyProvider, backoffPolicy1,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue