rls: fix wrong grpcKeybuilder field name (#8999)

The `grpcKeybuilders` [field](9fb243ce29/grpc/lookup/v1/rls_config.proto (L176)) should not be `grpcKeyBuilders` in json format.

The mistake in Java was introduced since the [beginning](0fd4975d4c (diff-585b634c79155b4ac9417f7805e1b9d5f6d5c11a940c88e27fdf53c209e619cfR104)).
This commit is contained in:
ZHANG Dapeng 2022-03-21 14:29:02 -07:00 committed by GitHub
parent d196e588a2
commit c772eb0f4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 23 additions and 23 deletions

View File

@ -109,12 +109,12 @@ final class RlsProtoConverters {
@Override
protected RouteLookupConfig doForward(Map<String, ?> json) {
ImmutableList<GrpcKeyBuilder> grpcKeyBuilders =
ImmutableList<GrpcKeyBuilder> grpcKeybuilders =
GrpcKeyBuilderConverter.covertAll(
checkNotNull(JsonUtil.getListOfObjects(json, "grpcKeyBuilders"), "grpcKeyBuilders"));
checkArgument(!grpcKeyBuilders.isEmpty(), "must have at least one GrpcKeyBuilder");
checkNotNull(JsonUtil.getListOfObjects(json, "grpcKeybuilders"), "grpcKeybuilders"));
checkArgument(!grpcKeybuilders.isEmpty(), "must have at least one GrpcKeyBuilder");
Set<Name> names = new HashSet<>();
for (GrpcKeyBuilder keyBuilder : grpcKeyBuilders) {
for (GrpcKeyBuilder keyBuilder : grpcKeybuilders) {
for (Name name : keyBuilder.names()) {
checkArgument(names.add(name), "duplicate names in grpc_keybuilders: " + name);
}
@ -147,7 +147,7 @@ final class RlsProtoConverters {
cacheSize = Math.min(cacheSize, MAX_CACHE_SIZE);
String defaultTarget = Strings.emptyToNull(JsonUtil.getString(json, "defaultTarget"));
return RouteLookupConfig.builder()
.grpcKeyBuilders(grpcKeyBuilders)
.grpcKeybuilders(grpcKeybuilders)
.lookupService(lookupService)
.lookupServiceTimeoutInNanos(timeout)
.maxAgeInNanos(maxAge)

View File

@ -75,7 +75,7 @@ final class RlsProtoData {
* keyed by name. If no GrpcKeyBuilder matches, an empty key_map will be sent to the lookup
* service; it should likely reply with a global default route and raise an alert.
*/
abstract ImmutableList<GrpcKeyBuilder> grpcKeyBuilders();
abstract ImmutableList<GrpcKeyBuilder> grpcKeybuilders();
/**
* Returns the name of the lookup service as a gRPC URI. Typically, this will be a subdomain of
@ -119,7 +119,7 @@ final class RlsProtoData {
@AutoValue.Builder
abstract static class Builder {
abstract Builder grpcKeyBuilders(ImmutableList<GrpcKeyBuilder> grpcKeyBuilders);
abstract Builder grpcKeybuilders(ImmutableList<GrpcKeyBuilder> grpcKeybuilders);
abstract Builder lookupService(String lookupService);

View File

@ -50,7 +50,7 @@ final class RlsRequestFactory {
private static Map<String, GrpcKeyBuilder> createKeyBuilderTable(
RouteLookupConfig config) {
Map<String, GrpcKeyBuilder> table = new HashMap<>();
for (GrpcKeyBuilder grpcKeyBuilder : config.grpcKeyBuilders()) {
for (GrpcKeyBuilder grpcKeyBuilder : config.grpcKeybuilders()) {
for (Name name : grpcKeyBuilder.names()) {
boolean hasMethod = name.method() == null || name.method().isEmpty();
String method = hasMethod ? "*" : name.method();

View File

@ -428,7 +428,7 @@ public class CachingRlsLbClientTest {
private static RouteLookupConfig getRouteLookupConfig() {
return RouteLookupConfig.builder()
.grpcKeyBuilders(ImmutableList.of(
.grpcKeybuilders(ImmutableList.of(
GrpcKeyBuilder.create(
ImmutableList.of(Name.create("service1", "create")),
ImmutableList.of(

View File

@ -392,7 +392,7 @@ public class RlsLoadBalancerTest {
private String getRlsConfigJsonStr() {
return "{\n"
+ " \"grpcKeyBuilders\": [\n"
+ " \"grpcKeybuilders\": [\n"
+ " {\n"
+ " \"names\": [\n"
+ " {\n"

View File

@ -101,7 +101,7 @@ public class RlsProtoConvertersTest {
@Test
public void convert_jsonRlsConfig() throws IOException {
String jsonStr = "{\n"
+ " \"grpcKeyBuilders\": [\n"
+ " \"grpcKeybuilders\": [\n"
+ " {\n"
+ " \"names\": [\n"
+ " {\n"
@ -177,7 +177,7 @@ public class RlsProtoConvertersTest {
RouteLookupConfig expectedConfig =
RouteLookupConfig.builder()
.grpcKeyBuilders(ImmutableList.of(
.grpcKeybuilders(ImmutableList.of(
GrpcKeyBuilder.create(
ImmutableList.of(Name.create("service1", "create")),
ImmutableList.of(
@ -216,7 +216,7 @@ public class RlsProtoConvertersTest {
@Test
public void convert_jsonRlsConfig_emptyKeyBuilders() throws IOException {
String jsonStr = "{\n"
+ " \"grpcKeyBuilders\": [],\n"
+ " \"grpcKeybuilders\": [],\n"
+ " \"lookupService\": \"service1\",\n"
+ " \"lookupServiceTimeout\": \"2s\",\n"
+ " \"maxAge\": \"300s\",\n"
@ -240,7 +240,7 @@ public class RlsProtoConvertersTest {
@Test
public void convert_jsonRlsConfig_namesNotUnique() throws IOException {
String jsonStr = "{\n"
+ " \"grpcKeyBuilders\": [\n"
+ " \"grpcKeybuilders\": [\n"
+ " {\n"
+ " \"names\": [\n"
+ " {\n"
@ -329,7 +329,7 @@ public class RlsProtoConvertersTest {
@Test
public void convert_jsonRlsConfig_defaultValues() throws IOException {
String jsonStr = "{\n"
+ " \"grpcKeyBuilders\": [\n"
+ " \"grpcKeybuilders\": [\n"
+ " {\n"
+ " \"names\": [\n"
+ " {\n"
@ -345,7 +345,7 @@ public class RlsProtoConvertersTest {
RouteLookupConfig expectedConfig =
RouteLookupConfig.builder()
.grpcKeyBuilders(ImmutableList.of(
.grpcKeybuilders(ImmutableList.of(
GrpcKeyBuilder.create(
ImmutableList.of(Name.create("service1", null)),
ImmutableList.<NameMatcher>of(),
@ -369,7 +369,7 @@ public class RlsProtoConvertersTest {
@Test
public void convert_jsonRlsConfig_staleAgeCappedByMaxAge() throws IOException {
String jsonStr = "{\n"
+ " \"grpcKeyBuilders\": [\n"
+ " \"grpcKeybuilders\": [\n"
+ " {\n"
+ " \"names\": [\n"
+ " {\n"
@ -402,7 +402,7 @@ public class RlsProtoConvertersTest {
RouteLookupConfig expectedConfig =
RouteLookupConfig.builder()
.grpcKeyBuilders(ImmutableList.of(
.grpcKeybuilders(ImmutableList.of(
GrpcKeyBuilder.create(
ImmutableList.of(Name.create("service1", "create")),
ImmutableList.of(
@ -428,7 +428,7 @@ public class RlsProtoConvertersTest {
@Test
public void convert_jsonRlsConfig_staleAgeGivenWithoutMaxAge() throws IOException {
String jsonStr = "{\n"
+ " \"grpcKeyBuilders\": [\n"
+ " \"grpcKeybuilders\": [\n"
+ " {\n"
+ " \"names\": [\n"
+ " {\n"
@ -472,7 +472,7 @@ public class RlsProtoConvertersTest {
@Test
public void convert_jsonRlsConfig_keyBuilderWithoutName() throws IOException {
String jsonStr = "{\n"
+ " \"grpcKeyBuilders\": [\n"
+ " \"grpcKeybuilders\": [\n"
+ " {\n"
+ " \"headers\": [\n"
+ " {\n"
@ -510,7 +510,7 @@ public class RlsProtoConvertersTest {
@Test
public void convert_jsonRlsConfig_nameWithoutService() throws IOException {
String jsonStr = "{\n"
+ " \"grpcKeyBuilders\": [\n"
+ " \"grpcKeybuilders\": [\n"
+ " {\n"
+ " \"names\": [\n"
+ " {\n"
@ -553,7 +553,7 @@ public class RlsProtoConvertersTest {
@Test
public void convert_jsonRlsConfig_keysNotUnique() throws IOException {
String jsonStr = "{\n"
+ " \"grpcKeyBuilders\": [\n"
+ " \"grpcKeybuilders\": [\n"
+ " {\n"
+ " \"names\": [\n"
+ " {\n"

View File

@ -37,7 +37,7 @@ public class RlsRequestFactoryTest {
private static final RouteLookupConfig RLS_CONFIG =
RouteLookupConfig.builder()
.grpcKeyBuilders(ImmutableList.of(
.grpcKeybuilders(ImmutableList.of(
GrpcKeyBuilder.create(
ImmutableList.of(Name.create("com.google.service1", "Create")),
ImmutableList.of(