mirror of https://github.com/grpc/grpc-java.git
xds: Unexpected types in server_features should be ignored
It was clearly defined in gRFC A30. The relevant text was copied as a comment in the code. As discovered due to grpc/grpc-go#7932
This commit is contained in:
parent
3b39a83621
commit
e8ff6da2cf
|
@ -248,7 +248,9 @@ public abstract class BootstrapperImpl extends Bootstrapper {
|
||||||
Object implSpecificConfig = getImplSpecificConfig(serverConfig, serverUri);
|
Object implSpecificConfig = getImplSpecificConfig(serverConfig, serverUri);
|
||||||
|
|
||||||
boolean ignoreResourceDeletion = false;
|
boolean ignoreResourceDeletion = false;
|
||||||
List<String> serverFeatures = JsonUtil.getListOfStrings(serverConfig, "server_features");
|
// "For forward compatibility reasons, the client will ignore any entry in the list that it
|
||||||
|
// does not understand, regardless of type."
|
||||||
|
List<?> serverFeatures = JsonUtil.getList(serverConfig, "server_features");
|
||||||
if (serverFeatures != null) {
|
if (serverFeatures != null) {
|
||||||
logger.log(XdsLogLevel.INFO, "Server features: {0}", serverFeatures);
|
logger.log(XdsLogLevel.INFO, "Server features: {0}", serverFeatures);
|
||||||
ignoreResourceDeletion = serverFeatures.contains(SERVER_FEATURE_IGNORE_RESOURCE_DELETION);
|
ignoreResourceDeletion = serverFeatures.contains(SERVER_FEATURE_IGNORE_RESOURCE_DELETION);
|
||||||
|
|
|
@ -676,6 +676,26 @@ public class GrpcBootstrapperImplTest {
|
||||||
assertThat(serverInfo.ignoreResourceDeletion()).isTrue();
|
assertThat(serverInfo.ignoreResourceDeletion()).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void serverFeatures_ignoresUnknownValues() throws XdsInitializationException {
|
||||||
|
String rawData = "{\n"
|
||||||
|
+ " \"xds_servers\": [\n"
|
||||||
|
+ " {\n"
|
||||||
|
+ " \"server_uri\": \"" + SERVER_URI + "\",\n"
|
||||||
|
+ " \"channel_creds\": [\n"
|
||||||
|
+ " {\"type\": \"insecure\"}\n"
|
||||||
|
+ " ],\n"
|
||||||
|
+ " \"server_features\": [null, {}, 3, true, \"unexpected\", \"trusted_xds_server\"]\n"
|
||||||
|
+ " }\n"
|
||||||
|
+ " ]\n"
|
||||||
|
+ "}";
|
||||||
|
|
||||||
|
bootstrapper.setFileReader(createFileReader(BOOTSTRAP_FILE_PATH, rawData));
|
||||||
|
BootstrapInfo info = bootstrapper.bootstrap();
|
||||||
|
ServerInfo serverInfo = Iterables.getOnlyElement(info.servers());
|
||||||
|
assertThat(serverInfo.isTrustedXdsServer()).isTrue();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void notFound() {
|
public void notFound() {
|
||||||
bootstrapper.bootstrapPathFromEnvVar = null;
|
bootstrapper.bootstrapPathFromEnvVar = null;
|
||||||
|
|
Loading…
Reference in New Issue