xDS: consistently use "override_host" instead of "host_override" (#32153)

* xDS: consistently use "override_host" instead of "host_override"

* fix test
pull/32154/head
Mark D. Roth 2 years ago committed by GitHub
parent 7a96bed837
commit c8407f8ef9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 4
      src/core/ext/filters/client_channel/lb_policy/xds/cds.cc
  2. 8
      src/core/ext/filters/client_channel/lb_policy/xds/xds_cluster_resolver.cc
  3. 2
      src/core/ext/filters/client_channel/lb_policy/xds/xds_override_host.cc
  4. 10
      src/core/ext/filters/stateful_session/stateful_session_filter.cc
  5. 4
      src/core/ext/filters/stateful_session/stateful_session_filter.h
  6. 14
      src/core/ext/xds/xds_cluster.cc
  7. 6
      src/core/ext/xds/xds_cluster.h
  8. 2
      src/core/ext/xds/xds_endpoint.cc
  9. 2
      src/core/ext/xds/xds_http_filters.cc
  10. 12
      test/core/client_channel/lb_policy/xds_override_host_test.cc
  11. 6
      test/core/xds/xds_cluster_resource_type_test.cc
  12. 2
      test/core/xds/xds_endpoint_resource_type_test.cc
  13. 4
      test/core/xds/xds_http_filters_test.cc

@ -465,9 +465,9 @@ absl::StatusOr<bool> CdsLb::GenerateDiscoveryMechanismForCluster(
mechanism["lrsLoadReportingServer"] =
state.update->lrs_load_reporting_server->ToJson();
}
if (!state.update->host_override_statuses.empty()) {
if (!state.update->override_host_statuses.empty()) {
Json::Array status_list;
for (const auto& status : state.update->host_override_statuses) {
for (const auto& status : state.update->override_host_statuses) {
status_list.emplace_back(status.ToString());
}
mechanism["overrideHostStatus"] = std::move(status_list);

@ -98,7 +98,7 @@ class XdsClusterResolverLbConfig : public LoadBalancingPolicy::Config {
std::string eds_service_name;
std::string dns_hostname;
Json::Array host_override_statuses;
Json::Array override_host_statuses;
// This is type Json::Object instead of OutlierDetectionConfig, because we
// don't actually need to validate the contents of the outlier detection
@ -115,7 +115,7 @@ class XdsClusterResolverLbConfig : public LoadBalancingPolicy::Config {
type == other.type &&
eds_service_name == other.eds_service_name &&
dns_hostname == other.dns_hostname &&
host_override_statuses == other.host_override_statuses &&
override_host_statuses == other.override_host_statuses &&
outlier_detection_lb_config == other.outlier_detection_lb_config);
}
@ -886,7 +886,7 @@ XdsClusterResolverLb::CreateChildPolicyConfigLocked() {
Json::Array xds_override_host_config = {Json::Object{
{"xds_override_host_experimental",
Json::Object{
{"overrideHostStatus", discovery_config.host_override_statuses},
{"overrideHostStatus", discovery_config.override_host_statuses},
{"childPolicy", std::move(child_policy)},
}}}};
// Wrap it in the xds_cluster_impl policy.
@ -1046,7 +1046,7 @@ XdsClusterResolverLbConfig::DiscoveryMechanism::JsonLoader(const JsonArgs&) {
.OptionalField("outlierDetection",
&DiscoveryMechanism::outlier_detection_lb_config)
.OptionalField("overrideHostStatus",
&DiscoveryMechanism::host_override_statuses)
&DiscoveryMechanism::override_host_statuses)
.Finish();
return loader;
}

@ -305,7 +305,7 @@ XdsOverrideHostLb::Picker::PickOverridenHost(absl::string_view override_host) {
LoadBalancingPolicy::PickResult XdsOverrideHostLb::Picker::Pick(
LoadBalancingPolicy::PickArgs args) {
auto* call_state = static_cast<LbCallStateInternal*>(args.call_state);
auto override_host = call_state->GetCallAttribute(XdsHostOverrideTypeName());
auto override_host = call_state->GetCallAttribute(XdsOverrideHostTypeName());
auto overridden_host_pick = PickOverridenHost(override_host);
if (overridden_host_pick.has_value()) {
return std::move(*overridden_host_pick);

@ -61,8 +61,8 @@ namespace grpc_core {
TraceFlag grpc_stateful_session_filter_trace(false, "stateful_session_filter");
UniqueTypeName XdsHostOverrideTypeName() {
static UniqueTypeName::Factory kFactory("xds_host_override");
UniqueTypeName XdsOverrideHostTypeName() {
static UniqueTypeName::Factory kFactory("xds_override_host");
return kFactory.Create();
}
@ -149,7 +149,7 @@ ArenaPromise<ServerMetadataHandle> StatefulSessionFilter::MakeCallPromise(
}
}
// Check to see if we have a host override cookie.
auto cookie_value = GetHostOverrideFromCookie(
auto cookie_value = GetOverrideHostFromCookie(
call_args.client_initial_metadata, *cookie_config->name);
if (cookie_value.has_value()) {
if (GRPC_TRACE_FLAG_ENABLED(grpc_stateful_session_filter_trace)) {
@ -160,7 +160,7 @@ ArenaPromise<ServerMetadataHandle> StatefulSessionFilter::MakeCallPromise(
}
// We have a valid cookie, so add the call attribute to be used by the
// xds_override_host LB policy.
service_config_call_data->SetCallAttribute(XdsHostOverrideTypeName(),
service_config_call_data->SetCallAttribute(XdsOverrideHostTypeName(),
*cookie_value);
}
// Intercept server initial metadata.
@ -193,7 +193,7 @@ ArenaPromise<ServerMetadataHandle> StatefulSessionFilter::MakeCallPromise(
}
absl::optional<absl::string_view>
StatefulSessionFilter::GetHostOverrideFromCookie(
StatefulSessionFilter::GetOverrideHostFromCookie(
const ClientMetadataHandle& client_initial_metadata,
absl::string_view cookie_name) {
// Check to see if the cookie header is present.

@ -34,7 +34,7 @@
namespace grpc_core {
UniqueTypeName XdsHostOverrideTypeName();
UniqueTypeName XdsOverrideHostTypeName();
// A filter to provide cookie-based stateful session affinity.
class StatefulSessionFilter : public ChannelFilter {
@ -51,7 +51,7 @@ class StatefulSessionFilter : public ChannelFilter {
private:
explicit StatefulSessionFilter(ChannelFilter::Args filter_args);
absl::optional<absl::string_view> GetHostOverrideFromCookie(
absl::optional<absl::string_view> GetOverrideHostFromCookie(
const ClientMetadataHandle& initial_metadata,
absl::string_view cookie_name);

@ -77,8 +77,8 @@ bool XdsCustomLbPolicyEnabled() {
}
// TODO(eostroukhov): Remove once this feature is no longer experimental.
bool XdsHostOverrideEnabled() {
auto value = GetEnv("GRPC_EXPERIMENTAL_XDS_ENABLE_HOST_OVERRIDE");
bool XdsOverrideHostEnabled() {
auto value = GetEnv("GRPC_EXPERIMENTAL_XDS_ENABLE_OVERRIDE_HOST");
if (!value.has_value()) return false;
bool parsed_value;
bool parse_succeeded = gpr_parse_bool_value(value->c_str(), &parsed_value);
@ -122,10 +122,10 @@ std::string XdsClusterResource::ToString() const {
}
contents.push_back(
absl::StrCat("max_concurrent_requests=", max_concurrent_requests));
if (!host_override_statuses.empty()) {
if (!override_host_statuses.empty()) {
std::vector<const char*> statuses;
statuses.reserve(host_override_statuses.size());
for (const auto& status : host_override_statuses) {
statuses.reserve(override_host_statuses.size());
for (const auto& status : override_host_statuses) {
statuses.push_back(status.ToString());
}
contents.push_back(absl::StrCat("override_host_statuses={",
@ -628,7 +628,7 @@ absl::StatusOr<XdsClusterResource> CdsResourceParse(
cds_update.outlier_detection = outlier_detection_update;
}
// Validate override host status.
if (XdsHostOverrideEnabled()) {
if (XdsOverrideHostEnabled()) {
const auto* common_lb_config =
envoy_config_cluster_v3_Cluster_common_lb_config(cluster);
if (common_lb_config != nullptr) {
@ -644,7 +644,7 @@ absl::StatusOr<XdsClusterResource> CdsResourceParse(
for (size_t i = 0; i < size; ++i) {
auto status = XdsHealthStatus::FromUpb(statuses[i]);
if (status.has_value()) {
cds_update.host_override_statuses.insert(*status);
cds_update.override_host_statuses.insert(*status);
}
}
}

@ -48,7 +48,7 @@
namespace grpc_core {
bool XdsCustomLbPolicyEnabled();
bool XdsHostOverrideEnabled();
bool XdsOverrideHostEnabled();
struct XdsClusterResource : public XdsResourceType::ResourceData {
struct Eds {
@ -98,7 +98,7 @@ struct XdsClusterResource : public XdsResourceType::ResourceData {
absl::optional<OutlierDetectionConfig> outlier_detection;
std::set<XdsHealthStatus> host_override_statuses;
std::set<XdsHealthStatus> override_host_statuses;
bool operator==(const XdsClusterResource& other) const {
return type == other.type && lb_policy_config == other.lb_policy_config &&
@ -106,7 +106,7 @@ struct XdsClusterResource : public XdsResourceType::ResourceData {
common_tls_context == other.common_tls_context &&
max_concurrent_requests == other.max_concurrent_requests &&
outlier_detection == other.outlier_detection &&
host_override_statuses == other.host_override_statuses;
override_host_statuses == other.override_host_statuses;
}
std::string ToString() const;

@ -154,7 +154,7 @@ absl::optional<ServerAddress> ServerAddressParse(
// health_status
const int32_t health_status =
envoy_config_endpoint_v3_LbEndpoint_health_status(lb_endpoint);
if (!XdsHostOverrideEnabled() &&
if (!XdsOverrideHostEnabled() &&
health_status != envoy_config_core_v3_UNKNOWN &&
health_status != envoy_config_core_v3_HEALTHY) {
return absl::nullopt;

@ -88,7 +88,7 @@ XdsHttpFilterRegistry::XdsHttpFilterRegistry(bool register_builtins) {
RegisterFilter(std::make_unique<XdsHttpRouterFilter>());
RegisterFilter(std::make_unique<XdsHttpFaultFilter>());
RegisterFilter(std::make_unique<XdsHttpRbacFilter>());
if (XdsHostOverrideEnabled()) {
if (XdsOverrideHostEnabled()) {
RegisterFilter(std::make_unique<XdsHttpStatefulSessionFilter>());
}
}

@ -102,10 +102,10 @@ TEST_F(XdsOverrideHostTest, OverrideHost) {
ASSERT_NE(picker, nullptr);
// Check that the host is overridden
std::map<UniqueTypeName, std::string> call_attributes{
{XdsHostOverrideTypeName(), "127.0.0.1:442"}};
{XdsOverrideHostTypeName(), "127.0.0.1:442"}};
EXPECT_EQ(ExpectPickComplete(picker.get(), call_attributes), kAddresses[1]);
EXPECT_EQ(ExpectPickComplete(picker.get(), call_attributes), kAddresses[1]);
call_attributes[XdsHostOverrideTypeName()] = std::string("127.0.0.1:441");
call_attributes[XdsOverrideHostTypeName()] = std::string("127.0.0.1:441");
EXPECT_EQ(ExpectPickComplete(picker.get(), call_attributes), kAddresses[0]);
EXPECT_EQ(ExpectPickComplete(picker.get(), call_attributes), kAddresses[0]);
}
@ -117,7 +117,7 @@ TEST_F(XdsOverrideHostTest, SubchannelNotFound) {
auto picker = ExpectStartupWithRoundRobin(kAddresses);
ASSERT_NE(picker, nullptr);
std::map<UniqueTypeName, std::string> call_attributes{
{XdsHostOverrideTypeName(), "no such host"}};
{XdsOverrideHostTypeName(), "no such host"}};
ExpectRoundRobinPicks(picker.get(), kAddresses, call_attributes);
}
@ -128,7 +128,7 @@ TEST_F(XdsOverrideHostTest, SubchannelsComeAndGo) {
ASSERT_NE(picker, nullptr);
// Check that the host is overridden
std::map<UniqueTypeName, std::string> call_attributes{
{XdsHostOverrideTypeName(), "127.0.0.1:442"}};
{XdsOverrideHostTypeName(), "127.0.0.1:442"}};
ExpectRoundRobinPicks(picker.get(), {kAddresses[1]}, call_attributes);
// Some other address is gone
EXPECT_EQ(ApplyUpdate(BuildUpdate({kAddresses[0], kAddresses[1]},
@ -174,7 +174,7 @@ TEST_F(XdsOverrideHostTest, FailedSubchannelIsNotPicked) {
ASSERT_NE(picker, nullptr);
// Check that the host is overridden
std::map<UniqueTypeName, std::string> pick_arg{
{XdsHostOverrideTypeName(), "127.0.0.1:442"}};
{XdsOverrideHostTypeName(), "127.0.0.1:442"}};
EXPECT_EQ(ExpectPickComplete(picker.get(), pick_arg), kAddresses[1]);
auto subchannel = FindSubchannel(kAddresses[1]);
ASSERT_NE(subchannel, nullptr);
@ -200,7 +200,7 @@ TEST_F(XdsOverrideHostTest, ConnectingSubchannelIsQueued) {
ASSERT_NE(picker, nullptr);
// Check that the host is overridden
std::map<UniqueTypeName, std::string> pick_arg{
{XdsHostOverrideTypeName(), "127.0.0.1:442"}};
{XdsOverrideHostTypeName(), "127.0.0.1:442"}};
EXPECT_EQ(ExpectPickComplete(picker.get(), pick_arg), kAddresses[1]);
auto subchannel = FindSubchannel(kAddresses[1]);
ASSERT_NE(subchannel, nullptr);

@ -1316,12 +1316,12 @@ TEST_F(HostOverrideStatusTest, IgnoredWhenNotEnabled) {
ASSERT_TRUE(decode_result.name.has_value());
EXPECT_EQ(*decode_result.name, "foo");
auto& resource = static_cast<XdsClusterResource&>(**decode_result.resource);
EXPECT_THAT(resource.host_override_statuses, ::testing::ElementsAre());
EXPECT_THAT(resource.override_host_statuses, ::testing::ElementsAre());
}
TEST_F(HostOverrideStatusTest, PassesOnRelevantHealthStatuses) {
ScopedExperimentalEnvVar env_var(
"GRPC_EXPERIMENTAL_XDS_ENABLE_HOST_OVERRIDE");
"GRPC_EXPERIMENTAL_XDS_ENABLE_OVERRIDE_HOST");
Cluster cluster;
cluster.set_name("foo");
cluster.set_type(cluster.EDS);
@ -1341,7 +1341,7 @@ TEST_F(HostOverrideStatusTest, PassesOnRelevantHealthStatuses) {
ASSERT_TRUE(decode_result.name.has_value());
EXPECT_EQ(*decode_result.name, "foo");
auto& resource = static_cast<XdsClusterResource&>(**decode_result.resource);
EXPECT_THAT(resource.host_override_statuses,
EXPECT_THAT(resource.override_host_statuses,
::testing::UnorderedElementsAre(
XdsHealthStatus(XdsHealthStatus::kUnknown),
XdsHealthStatus(XdsHealthStatus::kHealthy),

@ -961,7 +961,7 @@ TEST_F(XdsEndpointTest, IgnoresEndpointsInUnsupportedStates) {
TEST_F(XdsEndpointTest, EndpointHealthStatus) {
ScopedExperimentalEnvVar env_var(
"GRPC_EXPERIMENTAL_XDS_ENABLE_HOST_OVERRIDE");
"GRPC_EXPERIMENTAL_XDS_ENABLE_OVERRIDE_HOST");
ClusterLoadAssignment cla;
cla.set_cluster_name("foo");
auto* locality = cla.add_endpoints();

@ -943,7 +943,7 @@ TEST_F(XdsStatefulSessionFilterDisabledTest, FilterNotRegistered) {
class XdsStatefulSessionFilterTest : public XdsHttpFilterTest {
protected:
void SetUp() override {
SetEnv("GRPC_EXPERIMENTAL_XDS_ENABLE_HOST_OVERRIDE", "true");
SetEnv("GRPC_EXPERIMENTAL_XDS_ENABLE_OVERRIDE_HOST", "true");
registry_ = XdsHttpFilterRegistry();
XdsExtension extension = MakeXdsExtension(StatefulSession());
filter_ = GetFilter(extension.type);
@ -951,7 +951,7 @@ class XdsStatefulSessionFilterTest : public XdsHttpFilterTest {
}
void TearDown() override {
UnsetEnv("GRPC_EXPERIMENTAL_XDS_ENABLE_HOST_OVERRIDE");
UnsetEnv("GRPC_EXPERIMENTAL_XDS_ENABLE_OVERRIDE_HOST");
}
const XdsHttpFilterImpl* filter_;

Loading…
Cancel
Save