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:
Terry Wilson 2023-04-14 16:27:17 -07:00 committed by GitHub
parent be2a2fc3b8
commit 6e54ceb2d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 3 deletions

View File

@ -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();
}
});

View File

@ -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);