Skip to content

Commit

Permalink
xds: gate xDS timeout with env variable (#7504)
Browse files Browse the repository at this point in the history
  • Loading branch information
voidzcy committed Oct 12, 2020
1 parent f9b428a commit 46290ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions xds/src/main/java/io/grpc/xds/XdsNameResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ final class XdsNameResolver extends NameResolver {

static final CallOptions.Key<String> CLUSTER_SELECTION_KEY =
CallOptions.Key.create("io.grpc.xds.CLUSTER_SELECTION_KEY");
@VisibleForTesting
static boolean enableTimeout =
Boolean.parseBoolean(System.getenv("GRPC_XDS_EXPERIMENTAL_ENABLE_TIMEOUT"));

private final XdsLogger logger;
private final String authority;
Expand Down Expand Up @@ -354,9 +357,11 @@ public Result selectConfig(PickSubchannelArgs args) {
}
} while (!retainCluster(cluster));
// TODO(chengyuanzhang): avoid service config generation and parsing for each call.
Map<String, ?> rawServiceConfig =
generateServiceConfigWithMethodTimeoutConfig(
selectedRoute.getRouteAction().getTimeoutNano());
Map<String, ?> rawServiceConfig = Collections.emptyMap();
if (enableTimeout) {
rawServiceConfig = generateServiceConfigWithMethodTimeoutConfig(
selectedRoute.getRouteAction().getTimeoutNano());
}
ConfigOrError parsedServiceConfig = serviceConfigParser.parseServiceConfig(rawServiceConfig);
Object config = parsedServiceConfig.getConfig();
if (config == null) {
Expand Down
1 change: 1 addition & 0 deletions xds/src/test/java/io/grpc/xds/XdsNameResolverTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ XdsChannel createChannel(List<ServerInfo> servers) throws XdsInitializationExcep

@Before
public void setUp() {
XdsNameResolver.enableTimeout = true;
Bootstrapper bootstrapper = new Bootstrapper() {
@Override
public BootstrapInfo readBootstrap() {
Expand Down

0 comments on commit 46290ef

Please sign in to comment.