xds: log error and fail start() if server-listener-resource-name-template not set or not using xds_v3 (#8375)

This commit is contained in:
sanjaypujare 2021-08-03 13:01:09 -07:00 committed by GitHub
parent 57bd087cdf
commit 0d80c33bce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 3 deletions

View File

@ -125,14 +125,22 @@ public final class XdsClientWrapperForServerSds {
} }
} }
}; };
newServerApi = xdsClient.getBootstrapInfo().getServers().get(0).isUseProtocolV3();
if (!newServerApi) {
reportError(
new XdsInitializationException(
"requires use of xds_v3 in xds bootstrap"),
true);
return;
}
grpcServerResourceId = xdsClient.getBootstrapInfo() grpcServerResourceId = xdsClient.getBootstrapInfo()
.getServerListenerResourceNameTemplate(); .getServerListenerResourceNameTemplate();
newServerApi = xdsClient.getBootstrapInfo().getServers().get(0).isUseProtocolV3(); if (grpcServerResourceId == null) {
if (newServerApi && grpcServerResourceId == null) {
reportError( reportError(
new XdsInitializationException( new XdsInitializationException(
"missing server_listener_resource_name_template value in xds bootstrap"), "missing server_listener_resource_name_template value in xds bootstrap"),
true); true);
return;
} }
grpcServerResourceId = grpcServerResourceId.replaceAll("%s", "0.0.0.0:" + port); grpcServerResourceId = grpcServerResourceId.replaceAll("%s", "0.0.0.0:" + port);
xdsClient.watchLdsResource(grpcServerResourceId, listenerWatcher); xdsClient.watchLdsResource(grpcServerResourceId, listenerWatcher);

View File

@ -47,7 +47,7 @@ public class XdsServerTestHelper {
static final Bootstrapper.BootstrapInfo BOOTSTRAP_INFO = static final Bootstrapper.BootstrapInfo BOOTSTRAP_INFO =
new Bootstrapper.BootstrapInfo( new Bootstrapper.BootstrapInfo(
Arrays.asList( Arrays.asList(
new Bootstrapper.ServerInfo(SERVER_URI, InsecureChannelCredentials.create(), false)), new Bootstrapper.ServerInfo(SERVER_URI, InsecureChannelCredentials.create(), true)),
BOOTSTRAP_NODE, BOOTSTRAP_NODE,
null, null,
"grpc/server?udpa.resource.listening_address=%s"); "grpc/server?udpa.resource.listening_address=%s");