Skip to content

Commit

Permalink
feat: remove directpath enable env (#1657)
Browse files Browse the repository at this point in the history
  • Loading branch information
mohanli-ml committed May 1, 2023
1 parent 6672a50 commit 47851e8
Showing 1 changed file with 2 additions and 17 deletions.
Expand Up @@ -82,7 +82,6 @@
*/
@InternalExtensionOnly
public final class InstantiatingGrpcChannelProvider implements TransportChannelProvider {
static final String DIRECT_PATH_ENV_VAR = "GOOGLE_CLOUD_ENABLE_DIRECT_PATH";
private static final String DIRECT_PATH_ENV_DISABLE_DIRECT_PATH =
"GOOGLE_CLOUD_DISABLE_DIRECT_PATH";
private static final String DIRECT_PATH_ENV_ENABLE_XDS = "GOOGLE_CLOUD_ENABLE_DIRECT_PATH_XDS";
Expand Down Expand Up @@ -237,9 +236,7 @@ private TransportChannel createChannel() throws IOException {
channelPoolSettings, InstantiatingGrpcChannelProvider.this::createSingleChannel));
}

// TODO(mohanli): Use attemptDirectPath as the only indicator once setAttemptDirectPath is adapted
// and the env var is removed from client environment.
private boolean isDirectPathEnabled(String serviceAddress) {
private boolean isDirectPathEnabled() {
String disableDirectPathEnv = envProvider.getenv(DIRECT_PATH_ENV_DISABLE_DIRECT_PATH);
boolean isDirectPathDisabled = Boolean.parseBoolean(disableDirectPathEnv);
if (isDirectPathDisabled) {
Expand All @@ -249,16 +246,6 @@ private boolean isDirectPathEnabled(String serviceAddress) {
if (attemptDirectPath != null) {
return attemptDirectPath;
}
// Only check DIRECT_PATH_ENV_VAR when attemptDirectPath is not set.
String whiteList = envProvider.getenv(DIRECT_PATH_ENV_VAR);
if (whiteList == null) {
return false;
}
for (String service : whiteList.split(",")) {
if (!service.isEmpty() && serviceAddress.contains(service)) {
return true;
}
}
return false;
}

Expand Down Expand Up @@ -318,9 +305,7 @@ private ManagedChannel createSingleChannel() throws IOException {

// Check DirectPath traffic.
boolean isDirectPathXdsEnabled = false;
if (isDirectPathEnabled(serviceAddress)
&& isNonDefaultServiceAccountAllowed()
&& isOnComputeEngine()) {
if (isDirectPathEnabled() && isNonDefaultServiceAccountAllowed() && isOnComputeEngine()) {
CallCredentials callCreds = MoreCallCredentials.from(credentials);
ChannelCredentials channelCreds =
GoogleDefaultChannelCredentials.newBuilder().callCredentials(callCreds).build();
Expand Down

0 comments on commit 47851e8

Please sign in to comment.