mirror of https://github.com/grpc/grpc-java.git
rls: Refresh name resolution on rejected addresses (#10032)
If a child load balancer rejects the addresses it if given all we can do is to trigger a name resolution refresh and hope for a better set of addresses.
This commit is contained in:
parent
be2a2fc3b8
commit
6e54ceb2d1
|
@ -302,8 +302,10 @@ final class LbPolicyConfiguration {
|
|||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
lb.handleResolvedAddresses(
|
||||
childLbResolvedAddressFactory.create(lbConfig.getConfig()));
|
||||
if (!lb.acceptResolvedAddresses(
|
||||
childLbResolvedAddressFactory.create(lbConfig.getConfig()))) {
|
||||
helper.refreshNameResolution();
|
||||
}
|
||||
lb.requestConnection();
|
||||
}
|
||||
});
|
||||
|
|
|
@ -57,6 +57,7 @@ public class LbPolicyConfigurationTest {
|
|||
|
||||
private final Helper helper = mock(Helper.class);
|
||||
private final LoadBalancerProvider lbProvider = mock(LoadBalancerProvider.class);
|
||||
private final LoadBalancer lb = mock(LoadBalancer.class);
|
||||
private final SubchannelStateManager subchannelStateManager = new SubchannelStateManagerImpl();
|
||||
private final SubchannelPicker picker = mock(SubchannelPicker.class);
|
||||
private final ChildLbStatusListener childLbStatusListener = mock(ChildLbStatusListener.class);
|
||||
|
@ -91,7 +92,7 @@ public class LbPolicyConfigurationTest {
|
|||
}
|
||||
}))
|
||||
.when(helper).getSynchronizationContext();
|
||||
doReturn(mock(LoadBalancer.class)).when(lbProvider).newLoadBalancer(any(Helper.class));
|
||||
doReturn(lb).when(lbProvider).newLoadBalancer(any(Helper.class));
|
||||
doReturn(ConfigOrError.fromConfig(new Object()))
|
||||
.when(lbProvider).parseLoadBalancingPolicyConfig(ArgumentMatchers.<Map<String, ?>>any());
|
||||
}
|
||||
|
@ -120,6 +121,13 @@ public class LbPolicyConfigurationTest {
|
|||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void childPolicyWrapper_addressesRejected() {
|
||||
when(lb.acceptResolvedAddresses(any(ResolvedAddresses.class))).thenReturn(false);
|
||||
factory.createOrGet("target");
|
||||
verify(helper).refreshNameResolution();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void childLoadBalancingPolicy_effectiveChildPolicy() {
|
||||
LoadBalancerProvider mockProvider = mock(LoadBalancerProvider.class);
|
||||
|
|
Loading…
Reference in New Issue