Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Xds fallback #11254

Merged
merged 3 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions xds/src/main/java/io/grpc/xds/client/BootstrapperImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
@Internal
public abstract class BootstrapperImpl extends Bootstrapper {

public static final String GRPC_EXPERIMENTAL_XDS_FALLBACK =
"GRPC_EXPERIMENTAL_XDS_FALLBACK";

// Client features.
@VisibleForTesting
public static final String CLIENT_FEATURE_DISABLE_OVERPROVISIONING =
Expand All @@ -52,6 +55,9 @@
private static final String SERVER_FEATURE_IGNORE_RESOURCE_DELETION = "ignore_resource_deletion";
private static final String SERVER_FEATURE_TRUSTED_XDS_SERVER = "trusted_xds_server";

@VisibleForTesting
static boolean enableXdsFallback = GrpcUtil.getFlag(GRPC_EXPERIMENTAL_XDS_FALLBACK, false);

protected final XdsLogger logger;

protected FileReader reader = LocalFileReader.INSTANCE;
Expand All @@ -65,6 +71,7 @@
protected abstract Object getImplSpecificConfig(Map<String, ?> serverConfig, String serverUri)
throws XdsInitializationException;


/**
* Reads and parses bootstrap config. The config is expected to be in JSON format.
*/
Expand Down Expand Up @@ -103,6 +110,9 @@
throw new XdsInitializationException("Invalid bootstrap: 'xds_servers' does not exist.");
}
List<ServerInfo> servers = parseServerInfos(rawServerConfigs, logger);
if (servers.size() > 1 && !enableXdsFallback) {
servers = ImmutableList.of(servers.get(0));

Check warning on line 114 in xds/src/main/java/io/grpc/xds/client/BootstrapperImpl.java

View check run for this annotation

Codecov / codecov/patch

xds/src/main/java/io/grpc/xds/client/BootstrapperImpl.java#L114

Added line #L114 was not covered by tests
}
builder.servers(servers);

Node.Builder nodeBuilder = Node.newBuilder();
Expand Down Expand Up @@ -209,6 +219,9 @@
if (rawAuthorityServers == null || rawAuthorityServers.isEmpty()) {
authorityServers = servers;
} else {
if (rawAuthorityServers.size() > 1 && !enableXdsFallback) {
rawAuthorityServers = ImmutableList.of(rawAuthorityServers.get(0));

Check warning on line 223 in xds/src/main/java/io/grpc/xds/client/BootstrapperImpl.java

View check run for this annotation

Codecov / codecov/patch

xds/src/main/java/io/grpc/xds/client/BootstrapperImpl.java#L223

Added line #L223 was not covered by tests
}
authorityServers = parseServerInfos(rawAuthorityServers, logger);
}
authorityInfoMapBuilder.put(
Expand Down
Loading
Loading