mirror of https://github.com/grpc/grpc-java.git
rls: fix rls oobChannel grpclb config service name
The serviceName field in oobChannel grpclb config should not be null, otherwise it will default to the lbHelper.getAuthority(), which perviously defaulted to the lookup service before #7852, but has been overridden to the backend service for authentication in #7852.
This commit is contained in:
parent
97b705614b
commit
e73f31a561
|
|
@ -17,6 +17,7 @@ dependencies {
|
||||||
guavaDependency 'implementation'
|
guavaDependency 'implementation'
|
||||||
compileOnly libraries.javax_annotation
|
compileOnly libraries.javax_annotation
|
||||||
testImplementation libraries.truth,
|
testImplementation libraries.truth,
|
||||||
|
project(':grpc-grpclb'),
|
||||||
project(':grpc-testing'),
|
project(':grpc-testing'),
|
||||||
project(':grpc-testing-proto'),
|
project(':grpc-testing-proto'),
|
||||||
project(':grpc-core').sourceSets.test.output // for FakeClock
|
project(':grpc-core').sourceSets.test.output // for FakeClock
|
||||||
|
|
|
||||||
|
|
@ -162,11 +162,13 @@ final class CachingRlsLbClient {
|
||||||
rlsConfig.getLookupService(), helper.getUnsafeChannelCredentials());
|
rlsConfig.getLookupService(), helper.getUnsafeChannelCredentials());
|
||||||
rlsChannelBuilder.overrideAuthority(helper.getAuthority());
|
rlsChannelBuilder.overrideAuthority(helper.getAuthority());
|
||||||
if (enableOobChannelDirectPath) {
|
if (enableOobChannelDirectPath) {
|
||||||
|
Map<String, ?> directPathServiceConfig =
|
||||||
|
getDirectPathServiceConfig(rlsConfig.getLookupService());
|
||||||
logger.log(
|
logger.log(
|
||||||
ChannelLogLevel.DEBUG,
|
ChannelLogLevel.DEBUG,
|
||||||
"RLS channel direct path enabled. RLS channel service config: {0}",
|
"RLS channel direct path enabled. RLS channel service config: {0}",
|
||||||
getDirectpathServiceConfig());
|
directPathServiceConfig);
|
||||||
rlsChannelBuilder.defaultServiceConfig(getDirectpathServiceConfig());
|
rlsChannelBuilder.defaultServiceConfig(directPathServiceConfig);
|
||||||
rlsChannelBuilder.disableServiceConfigLookUp();
|
rlsChannelBuilder.disableServiceConfigLookUp();
|
||||||
}
|
}
|
||||||
rlsChannel = rlsChannelBuilder.build();
|
rlsChannel = rlsChannelBuilder.build();
|
||||||
|
|
@ -183,12 +185,14 @@ final class CachingRlsLbClient {
|
||||||
logger.log(ChannelLogLevel.DEBUG, "CachingRlsLbClient created");
|
logger.log(ChannelLogLevel.DEBUG, "CachingRlsLbClient created");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static ImmutableMap<String, Object> getDirectpathServiceConfig() {
|
private static ImmutableMap<String, Object> getDirectPathServiceConfig(String serviceName) {
|
||||||
ImmutableMap<String, Object> pickFirstStrategy =
|
ImmutableMap<String, Object> pickFirstStrategy =
|
||||||
ImmutableMap.<String, Object>of("pick_first", ImmutableMap.of());
|
ImmutableMap.<String, Object>of("pick_first", ImmutableMap.of());
|
||||||
|
|
||||||
ImmutableMap<String, Object> childPolicy =
|
ImmutableMap<String, Object> childPolicy =
|
||||||
ImmutableMap.<String, Object>of("childPolicy", ImmutableList.of(pickFirstStrategy));
|
ImmutableMap.<String, Object>of(
|
||||||
|
"childPolicy", ImmutableList.of(pickFirstStrategy),
|
||||||
|
"serviceName", serviceName);
|
||||||
|
|
||||||
ImmutableMap<String, Object> grpcLbPolicy =
|
ImmutableMap<String, Object> grpcLbPolicy =
|
||||||
ImmutableMap.<String, Object>of("grpclb", childPolicy);
|
ImmutableMap.<String, Object>of("grpclb", childPolicy);
|
||||||
|
|
|
||||||
|
|
@ -145,12 +145,16 @@ public class CachingRlsLbClientTest {
|
||||||
|
|
||||||
private CachingRlsLbClient rlsLbClient;
|
private CachingRlsLbClient rlsLbClient;
|
||||||
private boolean existingEnableOobChannelDirectPath;
|
private boolean existingEnableOobChannelDirectPath;
|
||||||
|
private Map<String, ?> rlsChannelServiceConfig;
|
||||||
|
private String rlsChannelOverriddenAuthority;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
existingEnableOobChannelDirectPath = CachingRlsLbClient.enableOobChannelDirectPath;
|
existingEnableOobChannelDirectPath = CachingRlsLbClient.enableOobChannelDirectPath;
|
||||||
CachingRlsLbClient.enableOobChannelDirectPath = false;
|
CachingRlsLbClient.enableOobChannelDirectPath = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setUpRlsLbClient() {
|
||||||
rlsLbClient =
|
rlsLbClient =
|
||||||
CachingRlsLbClient.newBuilder()
|
CachingRlsLbClient.newBuilder()
|
||||||
.setBackoffProvider(fakeBackoffProvider)
|
.setBackoffProvider(fakeBackoffProvider)
|
||||||
|
|
@ -185,6 +189,7 @@ public class CachingRlsLbClientTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void get_noError_lifeCycle() throws Exception {
|
public void get_noError_lifeCycle() throws Exception {
|
||||||
|
setUpRlsLbClient();
|
||||||
InOrder inOrder = inOrder(evictionListener);
|
InOrder inOrder = inOrder(evictionListener);
|
||||||
RouteLookupRequest routeLookupRequest =
|
RouteLookupRequest routeLookupRequest =
|
||||||
new RouteLookupRequest(
|
new RouteLookupRequest(
|
||||||
|
|
@ -233,8 +238,44 @@ public class CachingRlsLbClientTest {
|
||||||
inOrder.verifyNoMoreInteractions();
|
inOrder.verifyNoMoreInteractions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void rls_overDirectPath() throws Exception {
|
||||||
|
CachingRlsLbClient.enableOobChannelDirectPath = true;
|
||||||
|
setUpRlsLbClient();
|
||||||
|
RouteLookupRequest routeLookupRequest =
|
||||||
|
new RouteLookupRequest(
|
||||||
|
"bigtable.googleapis.com", "/foo/bar", "grpc", ImmutableMap.<String, String>of());
|
||||||
|
rlsServerImpl.setLookupTable(
|
||||||
|
ImmutableMap.of(
|
||||||
|
routeLookupRequest,
|
||||||
|
new RouteLookupResponse(ImmutableList.of("target"), "header")));
|
||||||
|
|
||||||
|
// initial request
|
||||||
|
CachedRouteLookupResponse resp = getInSyncContext(routeLookupRequest);
|
||||||
|
assertThat(resp.isPending()).isTrue();
|
||||||
|
|
||||||
|
// server response
|
||||||
|
fakeTimeProvider.forwardTime(SERVER_LATENCY_MILLIS, TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
|
resp = getInSyncContext(routeLookupRequest);
|
||||||
|
assertThat(resp.hasData()).isTrue();
|
||||||
|
|
||||||
|
assertThat(rlsChannelOverriddenAuthority).isEqualTo("bigtable.googleapis.com:443");
|
||||||
|
assertThat(rlsChannelServiceConfig).isEqualTo(
|
||||||
|
ImmutableMap.of(
|
||||||
|
"loadBalancingConfig",
|
||||||
|
ImmutableList.of(ImmutableMap.of(
|
||||||
|
"grpclb",
|
||||||
|
ImmutableMap.of(
|
||||||
|
"childPolicy",
|
||||||
|
ImmutableList.of(ImmutableMap.of("pick_first", ImmutableMap.of())),
|
||||||
|
"serviceName",
|
||||||
|
"service1")))));
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void get_throttledAndRecover() throws Exception {
|
public void get_throttledAndRecover() throws Exception {
|
||||||
|
setUpRlsLbClient();
|
||||||
RouteLookupRequest routeLookupRequest =
|
RouteLookupRequest routeLookupRequest =
|
||||||
new RouteLookupRequest("server", "/foo/bar", "grpc", ImmutableMap.<String, String>of());
|
new RouteLookupRequest("server", "/foo/bar", "grpc", ImmutableMap.<String, String>of());
|
||||||
rlsServerImpl.setLookupTable(
|
rlsServerImpl.setLookupTable(
|
||||||
|
|
@ -276,6 +317,7 @@ public class CachingRlsLbClientTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void get_updatesLbState() throws Exception {
|
public void get_updatesLbState() throws Exception {
|
||||||
|
setUpRlsLbClient();
|
||||||
InOrder inOrder = inOrder(helper);
|
InOrder inOrder = inOrder(helper);
|
||||||
RouteLookupRequest routeLookupRequest =
|
RouteLookupRequest routeLookupRequest =
|
||||||
new RouteLookupRequest(
|
new RouteLookupRequest(
|
||||||
|
|
@ -344,6 +386,7 @@ public class CachingRlsLbClientTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void get_childPolicyWrapper_reusedForSameTarget() throws Exception {
|
public void get_childPolicyWrapper_reusedForSameTarget() throws Exception {
|
||||||
|
setUpRlsLbClient();
|
||||||
RouteLookupRequest routeLookupRequest =
|
RouteLookupRequest routeLookupRequest =
|
||||||
new RouteLookupRequest("server", "/foo/bar", "grpc", ImmutableMap.<String, String>of());
|
new RouteLookupRequest("server", "/foo/bar", "grpc", ImmutableMap.<String, String>of());
|
||||||
RouteLookupRequest routeLookupRequest2 =
|
RouteLookupRequest routeLookupRequest2 =
|
||||||
|
|
@ -565,6 +608,20 @@ public class CachingRlsLbClientTest {
|
||||||
public ManagedChannel build() {
|
public ManagedChannel build() {
|
||||||
return grpcCleanupRule.register(super.build());
|
return grpcCleanupRule.register(super.build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CleaningChannelBuilder defaultServiceConfig(Map<String, ?> serviceConfig) {
|
||||||
|
rlsChannelServiceConfig = serviceConfig;
|
||||||
|
delegate().defaultServiceConfig(serviceConfig);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CleaningChannelBuilder overrideAuthority(String authority) {
|
||||||
|
rlsChannelOverriddenAuthority = authority;
|
||||||
|
delegate().overrideAuthority(authority);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new CleaningChannelBuilder();
|
return new CleaningChannelBuilder();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue