[xds] Remove variable protection from custom LB policies (#32888)

pull/32889/head
Eugene Ostroukhov 2 years ago committed by GitHub
parent bdae467be8
commit e59a3e25ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      doc/grpc_xds_features.md
  2. 48
      src/core/ext/xds/xds_cluster.cc
  3. 1
      src/core/ext/xds/xds_cluster.h
  4. 30
      test/core/xds/xds_cluster_resource_type_test.cc
  5. 1
      test/cpp/end2end/xds/xds_wrr_end2end_test.cc

@ -68,4 +68,4 @@ Support for [xDS v2 APIs](https://www.envoyproxy.io/docs/envoy/latest/api/api_su
[Security](https://www.envoyproxy.io/docs/envoy/latest/configuration/security/security):<br>Uses [certificate providers](https://github.com/grpc/proposal/blob/master/A29-xds-tls-security.md#certificate-provider-plugin-framework) instead of SDS | [A29](https://github.com/grpc/proposal/blob/master/A29-xds-tls-security.md) | v1.41.0<br>(C++ and Python) | v1.41.0 | 1.41.0 | |
[Authorization (RBAC)](https://www.envoyproxy.io/docs/envoy/latest/api-v3/extensions/filters/http/rbac/v3/rbac.proto):<br><ul><li>`LOG` action has no effect<li>CEL unsupported and rejected</ul> | [A41](https://github.com/grpc/proposal/blob/master/A41-xds-rbac.md) | v1.51.0<br>(C++ and Python) | v1.42.0 | 1.42.0 | |
[Outlier Detection](https://www.envoyproxy.io/docs/envoy/latest/intro/arch_overview/upstream/outlier):<br>Only the following detection types are supported:<ul><li>Success Rate</li><li>Failure Percentage</li></ul> | [A50](https://github.com/grpc/proposal/blob/master/A50-xds-outlier-detection.md) | v1.51.0 | v1.49.0 | v1.50.0 | v1.7.0 | |
[Custom Load Balancer Configuration](https://github.com/envoyproxy/envoy/blob/57be3189ffa3372b34e9480d1f02b2d165e49077/api/envoy/config/cluster/v3/cluster.proto#L1208)<br> | [A52](https://github.com/grpc/proposal/blob/master/A52-xds-custom-lb-policies.md) | | v1.47.0 | | |
[Custom Load Balancer Configuration](https://github.com/envoyproxy/envoy/blob/57be3189ffa3372b34e9480d1f02b2d165e49077/api/envoy/config/cluster/v3/cluster.proto#L1208)<br> | [A52](https://github.com/grpc/proposal/blob/master/A52-xds-custom-lb-policies.md) | v1.55.0 | v1.47.0 | | |

@ -68,15 +68,6 @@
namespace grpc_core {
// TODO(roth): Remove once custom LB policy support is no longer experimental.
bool XdsCustomLbPolicyEnabled() {
auto value = GetEnv("GRPC_EXPERIMENTAL_XDS_CUSTOM_LB_CONFIG");
if (!value.has_value()) return false;
bool parsed_value;
bool parse_succeeded = gpr_parse_bool_value(value->c_str(), &parsed_value);
return parse_succeeded && parsed_value;
}
// TODO(eostroukhov): Remove once this feature is no longer experimental.
bool XdsOverrideHostEnabled() {
auto value = GetEnv("GRPC_EXPERIMENTAL_XDS_ENABLE_OVERRIDE_HOST");
@ -323,28 +314,25 @@ void ParseLbPolicyConfig(const XdsResourceType::DecodeContext& context,
XdsClusterResource* cds_update,
ValidationErrors* errors) {
// First, check the new load_balancing_policy field.
if (XdsCustomLbPolicyEnabled()) {
const auto* load_balancing_policy =
envoy_config_cluster_v3_Cluster_load_balancing_policy(cluster);
if (load_balancing_policy != nullptr) {
const auto& registry =
static_cast<const GrpcXdsBootstrap&>(context.client->bootstrap())
.lb_policy_registry();
ValidationErrors::ScopedField field(errors, ".load_balancing_policy");
const size_t original_error_count = errors->size();
cds_update->lb_policy_config = registry.ConvertXdsLbPolicyConfig(
context, load_balancing_policy, errors);
// If there were no conversion errors, validate that the converted config
// parses with the gRPC LB policy registry.
if (original_error_count == errors->size()) {
auto config =
CoreConfiguration::Get()
.lb_policy_registry()
.ParseLoadBalancingConfig(cds_update->lb_policy_config);
if (!config.ok()) errors->AddError(config.status().message());
}
return;
const auto* load_balancing_policy =
envoy_config_cluster_v3_Cluster_load_balancing_policy(cluster);
if (load_balancing_policy != nullptr) {
const auto& registry =
static_cast<const GrpcXdsBootstrap&>(context.client->bootstrap())
.lb_policy_registry();
ValidationErrors::ScopedField field(errors, ".load_balancing_policy");
const size_t original_error_count = errors->size();
cds_update->lb_policy_config = registry.ConvertXdsLbPolicyConfig(
context, load_balancing_policy, errors);
// If there were no conversion errors, validate that the converted config
// parses with the gRPC LB policy registry.
if (original_error_count == errors->size()) {
auto config = CoreConfiguration::Get()
.lb_policy_registry()
.ParseLoadBalancingConfig(cds_update->lb_policy_config);
if (!config.ok()) errors->AddError(config.status().message());
}
return;
}
// Didn't find load_balancing_policy field, so fall back to the old
// lb_policy enum field.

@ -47,7 +47,6 @@
namespace grpc_core {
bool XdsCustomLbPolicyEnabled();
bool XdsOverrideHostEnabled();
struct XdsClusterResource : public XdsResourceType::ResourceData {

@ -779,7 +779,6 @@ TEST_F(LbPolicyTest, EnumUnsupportedPolicy) {
}
TEST_F(LbPolicyTest, LoadBalancingPolicyField) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_CUSTOM_LB_CONFIG");
Cluster cluster;
cluster.set_name("foo");
cluster.set_type(cluster.EDS);
@ -810,38 +809,10 @@ TEST_F(LbPolicyTest, LoadBalancingPolicyField) {
"\"childPolicy\":[{\"round_robin\":{}}]}}]");
}
TEST_F(LbPolicyTest, LoadBalancingPolicyFieldIgnoredUnlessEnabled) {
Cluster cluster;
cluster.set_name("foo");
cluster.set_type(cluster.EDS);
cluster.mutable_eds_cluster_config()->mutable_eds_config()->mutable_self();
// New field says to use round_robin, but the old enum field says to use
// ring_hash. The env var is not enabled, so we use the old enum field.
cluster.mutable_load_balancing_policy()
->add_policies()
->mutable_typed_extension_config()
->mutable_typed_config()
->PackFrom(RoundRobin());
cluster.set_lb_policy(cluster.RING_HASH);
std::string serialized_resource;
ASSERT_TRUE(cluster.SerializeToString(&serialized_resource));
auto* resource_type = XdsClusterResourceType::Get();
auto decode_result =
resource_type->Decode(decode_context_, serialized_resource);
ASSERT_TRUE(decode_result.resource.ok()) << decode_result.resource.status();
ASSERT_TRUE(decode_result.name.has_value());
EXPECT_EQ(*decode_result.name, "foo");
auto& resource = static_cast<XdsClusterResource&>(**decode_result.resource);
EXPECT_EQ(JsonDump(Json{resource.lb_policy_config}),
"[{\"ring_hash_experimental\":{"
"\"maxRingSize\":8388608,\"minRingSize\":1024}}]");
}
// This tests that we're passing along errors from XdsLbPolicyRegistry.
// A complete list of error cases for that class is in
// xds_lb_policy_registry_test.
TEST_F(LbPolicyTest, XdsLbPolicyRegistryConversionFails) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_CUSTOM_LB_CONFIG");
Cluster cluster;
cluster.set_name("foo");
cluster.set_type(cluster.EDS);
@ -870,7 +841,6 @@ TEST_F(LbPolicyTest, XdsLbPolicyRegistryConversionFails) {
}
TEST_F(LbPolicyTest, ConvertedCustomPolicyFailsValidation) {
ScopedExperimentalEnvVar env_var("GRPC_EXPERIMENTAL_XDS_CUSTOM_LB_CONFIG");
Cluster cluster;
cluster.set_name("foo");
cluster.set_type(cluster.EDS);

@ -48,7 +48,6 @@ INSTANTIATE_TEST_SUITE_P(XdsTest, WrrTest, ::testing::Values(XdsTestType()),
&XdsTestType::Name);
TEST_P(WrrTest, Basic) {
ScopedExperimentalEnvVar env_var1("GRPC_EXPERIMENTAL_XDS_CUSTOM_LB_CONFIG");
ScopedExperimentalEnvVar env_var2("GRPC_EXPERIMENTAL_XDS_WRR_LB");
CreateAndStartBackends(3);
// Expected weights = qps / (cpu_util + (eps/qps)) =

Loading…
Cancel
Save