xds: remove GRPC_XDS_EXPERIMENTAL_V3_SUPPORT env flag

This commit is contained in:
ZHANG Dapeng 2021-02-08 13:42:43 -08:00 committed by GitHub
parent 14332d294c
commit b1daad6f30
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 25 deletions

View File

@ -59,9 +59,6 @@ public class BootstrapperImpl implements Bootstrapper {
static String bootstrapConfigFromSysProp = System.getProperty(BOOTSTRAP_CONFIG_SYS_PROPERTY_VAR); static String bootstrapConfigFromSysProp = System.getProperty(BOOTSTRAP_CONFIG_SYS_PROPERTY_VAR);
private static final String XDS_V3_SERVER_FEATURE = "xds_v3"; private static final String XDS_V3_SERVER_FEATURE = "xds_v3";
@VisibleForTesting @VisibleForTesting
static boolean enableV3Protocol = Boolean.parseBoolean(
System.getenv("GRPC_XDS_EXPERIMENTAL_V3_SUPPORT"));
@VisibleForTesting
static final String CLIENT_FEATURE_DISABLE_OVERPROVISIONING = static final String CLIENT_FEATURE_DISABLE_OVERPROVISIONING =
"envoy.lb.does_not_support_overprovisioning"; "envoy.lb.does_not_support_overprovisioning";
@ -176,8 +173,7 @@ public class BootstrapperImpl implements Bootstrapper {
List<String> serverFeatures = JsonUtil.getListOfStrings(serverConfig, "server_features"); List<String> serverFeatures = JsonUtil.getListOfStrings(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);
useProtocolV3 = enableV3Protocol useProtocolV3 = serverFeatures.contains(XDS_V3_SERVER_FEATURE);
&& serverFeatures.contains(XDS_V3_SERVER_FEATURE);
} }
servers.add(new ServerInfo(serverUri, channelCredentials, useProtocolV3)); servers.add(new ServerInfo(serverUri, channelCredentials, useProtocolV3));
} }

View File

@ -56,7 +56,6 @@ public class BootstrapperImplTest {
private String originalBootstrapPathFromSysProp; private String originalBootstrapPathFromSysProp;
private String originalBootstrapConfigFromEnvVar; private String originalBootstrapConfigFromEnvVar;
private String originalBootstrapConfigFromSysProp; private String originalBootstrapConfigFromSysProp;
private boolean originalEnableV3Protocol;
@Before @Before
public void setUp() { public void setUp() {
@ -69,7 +68,6 @@ public class BootstrapperImplTest {
originalBootstrapPathFromSysProp = BootstrapperImpl.bootstrapPathFromSysProp; originalBootstrapPathFromSysProp = BootstrapperImpl.bootstrapPathFromSysProp;
originalBootstrapConfigFromEnvVar = BootstrapperImpl.bootstrapConfigFromEnvVar; originalBootstrapConfigFromEnvVar = BootstrapperImpl.bootstrapConfigFromEnvVar;
originalBootstrapConfigFromSysProp = BootstrapperImpl.bootstrapConfigFromSysProp; originalBootstrapConfigFromSysProp = BootstrapperImpl.bootstrapConfigFromSysProp;
originalEnableV3Protocol = BootstrapperImpl.enableV3Protocol;
} }
@After @After
@ -78,7 +76,6 @@ public class BootstrapperImplTest {
BootstrapperImpl.bootstrapPathFromSysProp = originalBootstrapPathFromSysProp; BootstrapperImpl.bootstrapPathFromSysProp = originalBootstrapPathFromSysProp;
BootstrapperImpl.bootstrapConfigFromEnvVar = originalBootstrapConfigFromEnvVar; BootstrapperImpl.bootstrapConfigFromEnvVar = originalBootstrapConfigFromEnvVar;
BootstrapperImpl.bootstrapConfigFromSysProp = originalBootstrapConfigFromSysProp; BootstrapperImpl.bootstrapConfigFromSysProp = originalBootstrapConfigFromSysProp;
BootstrapperImpl.enableV3Protocol = originalEnableV3Protocol;
} }
@Test @Test
@ -567,7 +564,7 @@ public class BootstrapperImplTest {
+ " \"channel_creds\": [\n" + " \"channel_creds\": [\n"
+ " {\"type\": \"insecure\"}\n" + " {\"type\": \"insecure\"}\n"
+ " ],\n" + " ],\n"
+ " \"server_features\": [\"xds_v3\"]\n" + " \"server_features\": []\n"
+ " }\n" + " }\n"
+ " ]\n" + " ]\n"
+ "}"; + "}";
@ -581,17 +578,7 @@ public class BootstrapperImplTest {
} }
@Test @Test
public void supportV3Protocol_disabledByDefault() throws XdsInitializationException { public void useV3ProtocolIfV3FeaturePresent() throws XdsInitializationException {
subtestSupportV3Protocol(false);
}
@Test
public void supportV3Protocol_enabled() throws XdsInitializationException {
BootstrapperImpl.enableV3Protocol = true;
subtestSupportV3Protocol(true);
}
private void subtestSupportV3Protocol(boolean enabled) throws XdsInitializationException {
String rawData = "{\n" String rawData = "{\n"
+ " \"xds_servers\": [\n" + " \"xds_servers\": [\n"
+ " {\n" + " {\n"
@ -609,11 +596,7 @@ public class BootstrapperImplTest {
ServerInfo serverInfo = Iterables.getOnlyElement(info.getServers()); ServerInfo serverInfo = Iterables.getOnlyElement(info.getServers());
assertThat(serverInfo.getTarget()).isEqualTo(SERVER_URI); assertThat(serverInfo.getTarget()).isEqualTo(SERVER_URI);
assertThat(serverInfo.getChannelCredentials()).isInstanceOf(InsecureChannelCredentials.class); assertThat(serverInfo.getChannelCredentials()).isInstanceOf(InsecureChannelCredentials.class);
if (enabled) { assertThat(serverInfo.isUseProtocolV3()).isTrue();
assertThat(serverInfo.isUseProtocolV3()).isTrue();
} else {
assertThat(serverInfo.isUseProtocolV3()).isFalse();
}
} }
@Test @Test