mirror of https://github.com/grpc/grpc-java.git
xds: shut down EDS downstream LB policies when no usable endpoints received (#7452)
This commit is contained in:
parent
2e411512be
commit
10b960ea5d
|
|
@ -275,10 +275,8 @@ final class EdsLoadBalancer2 extends LoadBalancer {
|
|||
locality, localityLbInfo.getLocalityWeight());
|
||||
}
|
||||
if (prioritizedLocalityWeights.isEmpty()) {
|
||||
lbHelper.helper.updateBalancingState(
|
||||
TRANSIENT_FAILURE,
|
||||
new ErrorPicker(
|
||||
Status.UNAVAILABLE.withDescription("No usable priority/locality/endpoint")));
|
||||
propagateResourceError(
|
||||
Status.UNAVAILABLE.withDescription("No usable priority/locality/endpoint"));
|
||||
return;
|
||||
}
|
||||
if (lb == null) {
|
||||
|
|
@ -310,15 +308,8 @@ final class EdsLoadBalancer2 extends LoadBalancer {
|
|||
@Override
|
||||
public void onResourceDoesNotExist(String resourceName) {
|
||||
logger.log(XdsLogLevel.INFO, "Resource {0} is unavailable", resourceName);
|
||||
if (lb != null) {
|
||||
lb.shutdown();
|
||||
lb = null;
|
||||
}
|
||||
lbHelper.helper.updateBalancingState(
|
||||
TRANSIENT_FAILURE,
|
||||
new ErrorPicker(
|
||||
Status.UNAVAILABLE.withDescription(
|
||||
"Resource " + resourceName + " is unavailable")));
|
||||
propagateResourceError(
|
||||
Status.UNAVAILABLE.withDescription("Resource " + resourceName + " is unavailable"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -330,6 +321,14 @@ final class EdsLoadBalancer2 extends LoadBalancer {
|
|||
}
|
||||
}
|
||||
|
||||
private void propagateResourceError(Status error) {
|
||||
if (lb != null) {
|
||||
lb.shutdown();
|
||||
lb = null;
|
||||
}
|
||||
lbHelper.helper.updateBalancingState(TRANSIENT_FAILURE, new ErrorPicker(error));
|
||||
}
|
||||
|
||||
private final class DropHandlingLbHelper extends ForwardingLoadBalancerHelper {
|
||||
private final Helper helper;
|
||||
private List<DropOverload> dropPolicies = Collections.emptyList();
|
||||
|
|
|
|||
|
|
@ -406,6 +406,27 @@ public class EdsLoadBalancer2Test {
|
|||
.isEqualTo("No usable priority/locality/endpoint");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleEndpointResource_shutDownExistingChildLbPoliciesIfNoUsableEndpoints() {
|
||||
deliverSimpleClusterLoadAssignment(EDS_SERVICE_NAME);
|
||||
FakeLoadBalancer childBalancer = Iterables.getOnlyElement(downstreamBalancers);
|
||||
assertThat(childBalancer.shutdown).isFalse();
|
||||
|
||||
EquivalentAddressGroup endpoint1 = makeAddress("endpoint-addr-1");
|
||||
LocalityLbEndpoints localityLbEndpoints1 =
|
||||
buildLocalityLbEndpoints(1, 10, Collections.singletonMap(endpoint1, false));
|
||||
xdsClient.deliverClusterLoadAssignment(
|
||||
EDS_SERVICE_NAME, Collections.singletonMap(locality1, localityLbEndpoints1));
|
||||
|
||||
assertThat(childBalancer.shutdown).isTrue();
|
||||
assertThat(currentState).isEqualTo(ConnectivityState.TRANSIENT_FAILURE);
|
||||
PickResult result = currentPicker.pickSubchannel(mock(PickSubchannelArgs.class));
|
||||
assertThat(result.getStatus().isOk()).isFalse();
|
||||
assertThat(result.getStatus().getCode()).isEqualTo(Code.UNAVAILABLE);
|
||||
assertThat(result.getStatus().getDescription())
|
||||
.isEqualTo("No usable priority/locality/endpoint");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void handleDrops() {
|
||||
FakeLoadBalancerProvider fakeRoundRobinProvider = new FakeLoadBalancerProvider("round_robin");
|
||||
|
|
|
|||
Loading…
Reference in New Issue