From c6e4cc7c033ad5b853d42661dc6576db98e32d8f Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Sun, 12 Jan 2020 18:11:43 -0500 Subject: [PATCH 1/7] api: deprecate hosts in Cluster. Now that we have stable Envoy API versioning, deprecate in v2, with the understanding that we won't ever make this a runtime controlled field. Risk level: Low Testing: CI Signed-off-by: Harvey Tuch --- api/envoy/api/v2/cluster.proto | 2 +- .../config/cluster/v3alpha/cluster.proto | 19 ++----------------- .../envoy/api/v2/cluster.proto | 2 +- .../config/cluster/v3alpha/cluster.proto | 2 +- .../upstream/health_discovery_service.cc | 4 ++-- source/common/upstream/logical_dns_cluster.cc | 7 ++++--- .../common/upstream/original_dst_cluster.cc | 2 +- source/common/upstream/static_cluster.cc | 5 +++-- source/common/upstream/strict_dns_cluster.cc | 5 +++-- .../clusters/redis/redis_cluster.cc | 7 ++++--- test/config/utility.cc | 16 +++++++++------- .../redis/redis_cluster_integration_test.cc | 7 ++++--- .../udp_proxy/udp_proxy_integration_test.cc | 8 +++++--- .../custom_cluster_integration_test.cc | 2 +- test/integration/eds_integration_test.cc | 2 +- test/integration/hds_integration_test.cc | 2 +- test/integration/http2_integration_test.cc | 4 ++-- .../http_subset_lb_integration_test.cc | 2 +- .../load_stats_integration_test.cc | 2 +- test/integration/protocol_integration_test.cc | 10 ++++++---- .../proxy_proto_integration_test.cc | 4 ++-- test/integration/stats_integration_test.cc | 2 +- ...transport_socket_match_integration_test.cc | 2 +- test/integration/uds_integration_test.h | 6 +++--- test/server/server_fuzz_test.cc | 2 +- 25 files changed, 61 insertions(+), 65 deletions(-) diff --git a/api/envoy/api/v2/cluster.proto b/api/envoy/api/v2/cluster.proto index a92dd0b0b3e8b..154c861fd1513 100644 --- a/api/envoy/api/v2/cluster.proto +++ b/api/envoy/api/v2/cluster.proto @@ -551,7 +551,7 @@ message Cluster { // **This field is deprecated**. Set the // :ref:`load_assignment` field instead. // - repeated core.Address hosts = 7; + repeated core.Address hosts = 7 [deprecated = true]; // Setting this is required for specifying members of // :ref:`STATIC`, diff --git a/api/envoy/config/cluster/v3alpha/cluster.proto b/api/envoy/config/cluster/v3alpha/cluster.proto index 9e3ede65efe96..83e8c017d401f 100644 --- a/api/envoy/config/cluster/v3alpha/cluster.proto +++ b/api/envoy/config/cluster/v3alpha/cluster.proto @@ -491,9 +491,9 @@ message Cluster { google.protobuf.Duration max_interval = 2 [(validate.rules).duration = {gt {nanos: 1000000}}]; } - reserved 12, 15, 11, 35; + reserved 12, 15, 7, 11, 35; - reserved "tls_context", "extension_protocol_options"; + reserved "hosts", "tls_context", "extension_protocol_options"; // Configuration to use different transport sockets for different endpoints. // The entry of *envoy.transport_socket* in the @@ -578,21 +578,6 @@ message Cluster { // when picking a host in the cluster. LbPolicy lb_policy = 6 [(validate.rules).enum = {defined_only: true}]; - // If the service discovery type is - // :ref:`STATIC`, - // :ref:`STRICT_DNS` - // or - // :ref:`LOGICAL_DNS`, - // then hosts is required. - // - // .. attention:: - // - // **This field is deprecated**. Set the - // :ref:`load_assignment` field - // instead. - // - repeated core.v3alpha.Address hosts = 7; - // Setting this is required for specifying members of // :ref:`STATIC`, // :ref:`STRICT_DNS` diff --git a/generated_api_shadow/envoy/api/v2/cluster.proto b/generated_api_shadow/envoy/api/v2/cluster.proto index a92dd0b0b3e8b..154c861fd1513 100644 --- a/generated_api_shadow/envoy/api/v2/cluster.proto +++ b/generated_api_shadow/envoy/api/v2/cluster.proto @@ -551,7 +551,7 @@ message Cluster { // **This field is deprecated**. Set the // :ref:`load_assignment` field instead. // - repeated core.Address hosts = 7; + repeated core.Address hosts = 7 [deprecated = true]; // Setting this is required for specifying members of // :ref:`STATIC`, diff --git a/generated_api_shadow/envoy/config/cluster/v3alpha/cluster.proto b/generated_api_shadow/envoy/config/cluster/v3alpha/cluster.proto index 1a502f636c8d3..6ab4df3c82fe2 100644 --- a/generated_api_shadow/envoy/config/cluster/v3alpha/cluster.proto +++ b/generated_api_shadow/envoy/config/cluster/v3alpha/cluster.proto @@ -596,7 +596,7 @@ message Cluster { // :ref:`load_assignment` field // instead. // - repeated core.v3alpha.Address hosts = 7; + repeated core.v3alpha.Address hidden_envoy_deprecated_hosts = 7 [deprecated = true]; // Setting this is required for specifying members of // :ref:`STATIC`, diff --git a/source/common/upstream/health_discovery_service.cc b/source/common/upstream/health_discovery_service.cc index 6a6e7c4abf41a..7e372baeb823f 100644 --- a/source/common/upstream/health_discovery_service.cc +++ b/source/common/upstream/health_discovery_service.cc @@ -154,7 +154,7 @@ void HdsDelegate::processMessage( // Add endpoints to cluster for (const auto& locality_endpoints : cluster_health_check.locality_endpoints()) { for (const auto& endpoint : locality_endpoints.endpoints()) { - cluster_config.add_hosts()->MergeFrom(endpoint.address()); + cluster_config.add_hidden_envoy_deprecated_hosts()->MergeFrom(endpoint.address()); } } @@ -231,7 +231,7 @@ HdsCluster::HdsCluster(Server::Admin& admin, Runtime::Loader& runtime, {admin, runtime_, cluster_, bind_config_, stats_, ssl_context_manager_, added_via_api_, cm, local_info, dispatcher, random, singleton_manager, tls, validation_visitor, api}); - for (const auto& host : cluster.hosts()) { + for (const auto& host : cluster.hidden_envoy_deprecated_hosts()) { initial_hosts_->emplace_back(new HostImpl( info_, "", Network::Address::resolveProtoAddress(host), envoy::config::core::v3alpha::Metadata::default_instance(), 1, diff --git a/source/common/upstream/logical_dns_cluster.cc b/source/common/upstream/logical_dns_cluster.cc index fb4c5a61a1b08..ff7edf982b561 100644 --- a/source/common/upstream/logical_dns_cluster.cc +++ b/source/common/upstream/logical_dns_cluster.cc @@ -55,9 +55,10 @@ LogicalDnsCluster::LogicalDnsCluster( resolve_timer_( factory_context.dispatcher().createTimer([this]() -> void { startResolve(); })), local_info_(factory_context.localInfo()), - load_assignment_(cluster.has_load_assignment() - ? convertPriority(cluster.load_assignment()) - : Config::Utility::translateClusterHosts(cluster.hosts())) { + load_assignment_( + cluster.has_load_assignment() + ? convertPriority(cluster.load_assignment()) + : Config::Utility::translateClusterHosts(cluster.hidden_envoy_deprecated_hosts())) { failure_backoff_strategy_ = Config::Utility::prepareDnsRefreshStrategy( cluster, dns_refresh_rate_ms_.count(), factory_context.random()); diff --git a/source/common/upstream/original_dst_cluster.cc b/source/common/upstream/original_dst_cluster.cc index 9440aa9e9e942..a2d7a1461b5b3 100644 --- a/source/common/upstream/original_dst_cluster.cc +++ b/source/common/upstream/original_dst_cluster.cc @@ -116,7 +116,7 @@ OriginalDstCluster::OriginalDstCluster( : false), host_map_(std::make_shared()) { // TODO(dio): Remove hosts check once the hosts field is removed. - if (config.has_load_assignment() || !config.hosts().empty()) { + if (config.has_load_assignment() || !config.hidden_envoy_deprecated_hosts().empty()) { throw EnvoyException("ORIGINAL_DST clusters must have no load assignment or hosts configured"); } cleanup_timer_->enableTimer(cleanup_interval_ms_); diff --git a/source/common/upstream/static_cluster.cc b/source/common/upstream/static_cluster.cc index 1f235cdc0bb4a..a1d537585bb65 100644 --- a/source/common/upstream/static_cluster.cc +++ b/source/common/upstream/static_cluster.cc @@ -16,8 +16,9 @@ StaticClusterImpl::StaticClusterImpl( new PriorityStateManager(*this, factory_context.localInfo(), nullptr)) { // TODO(dio): Use by-reference when cluster.hosts() is removed. const envoy::config::endpoint::v3alpha::ClusterLoadAssignment cluster_load_assignment( - cluster.has_load_assignment() ? cluster.load_assignment() - : Config::Utility::translateClusterHosts(cluster.hosts())); + cluster.has_load_assignment() + ? cluster.load_assignment() + : Config::Utility::translateClusterHosts(cluster.hidden_envoy_deprecated_hosts())); overprovisioning_factor_ = PROTOBUF_GET_WRAPPED_OR_DEFAULT( cluster_load_assignment.policy(), overprovisioning_factor, kDefaultOverProvisioningFactor); diff --git a/source/common/upstream/strict_dns_cluster.cc b/source/common/upstream/strict_dns_cluster.cc index 45d6b2ffa15b1..c1992a95632f2 100644 --- a/source/common/upstream/strict_dns_cluster.cc +++ b/source/common/upstream/strict_dns_cluster.cc @@ -24,8 +24,9 @@ StrictDnsClusterImpl::StrictDnsClusterImpl( std::list resolve_targets; const envoy::config::endpoint::v3alpha::ClusterLoadAssignment load_assignment( - cluster.has_load_assignment() ? cluster.load_assignment() - : Config::Utility::translateClusterHosts(cluster.hosts())); + cluster.has_load_assignment() + ? cluster.load_assignment() + : Config::Utility::translateClusterHosts(cluster.hidden_envoy_deprecated_hosts())); const auto& locality_lb_endpoints = load_assignment.endpoints(); for (const auto& locality_lb_endpoint : locality_lb_endpoints) { validateEndpointsForZoneAwareRouting(locality_lb_endpoint); diff --git a/source/extensions/clusters/redis/redis_cluster.cc b/source/extensions/clusters/redis/redis_cluster.cc index be8704841f813..3faff0b8fdad3 100644 --- a/source/extensions/clusters/redis/redis_cluster.cc +++ b/source/extensions/clusters/redis/redis_cluster.cc @@ -41,9 +41,10 @@ RedisCluster::RedisCluster( host_degraded_refresh_threshold_(redis_cluster.host_degraded_refresh_threshold()), dispatcher_(factory_context.dispatcher()), dns_resolver_(std::move(dns_resolver)), dns_lookup_family_(Upstream::getDnsLookupFamilyFromCluster(cluster)), - load_assignment_(cluster.has_load_assignment() - ? cluster.load_assignment() - : Config::Utility::translateClusterHosts(cluster.hosts())), + load_assignment_( + cluster.has_load_assignment() + ? cluster.load_assignment() + : Config::Utility::translateClusterHosts(cluster.hidden_envoy_deprecated_hosts())), local_info_(factory_context.localInfo()), random_(factory_context.random()), redis_discovery_session_(*this, redis_client_factory), lb_factory_(std::move(lb_factory)), auth_password_( diff --git a/test/config/utility.cc b/test/config/utility.cc index c866e12afb8aa..5a6014a31b5c5 100644 --- a/test/config/utility.cc +++ b/test/config/utility.cc @@ -348,10 +348,11 @@ ConfigHelper::ConfigHelper(const Network::Address::IpVersion version, Api::Api& for (int i = 0; i < static_resources->clusters_size(); ++i) { auto* cluster = static_resources->mutable_clusters(i); - if (!cluster->hosts().empty()) { - for (int j = 0; j < cluster->hosts().size(); j++) { - if (cluster->mutable_hosts(j)->has_socket_address()) { - auto host_socket_addr = cluster->mutable_hosts(j)->mutable_socket_address(); + if (!cluster->hidden_envoy_deprecated_hosts().empty()) { + for (int j = 0; j < cluster->hidden_envoy_deprecated_hosts().size(); j++) { + if (cluster->mutable_hidden_envoy_deprecated_hosts(j)->has_socket_address()) { + auto host_socket_addr = + cluster->mutable_hidden_envoy_deprecated_hosts(j)->mutable_socket_address(); host_socket_addr->set_address(Network::Test::getLoopbackAddressString(version)); } } @@ -417,9 +418,10 @@ void ConfigHelper::finalize(const std::vector& ports) { } else if (cluster->has_cluster_type()) { custom_cluster = true; } else { - for (int j = 0; j < cluster->hosts_size(); ++j) { - if (cluster->mutable_hosts(j)->has_socket_address()) { - auto* host_socket_addr = cluster->mutable_hosts(j)->mutable_socket_address(); + for (int j = 0; j < cluster->hidden_envoy_deprecated_hosts_size(); ++j) { + if (cluster->mutable_hidden_envoy_deprecated_hosts(j)->has_socket_address()) { + auto* host_socket_addr = + cluster->mutable_hidden_envoy_deprecated_hosts(j)->mutable_socket_address(); RELEASE_ASSERT(ports.size() > port_idx, ""); host_socket_addr->set_port_value(ports[port_idx++]); } diff --git a/test/extensions/clusters/redis/redis_cluster_integration_test.cc b/test/extensions/clusters/redis/redis_cluster_integration_test.cc index 46e3b96e75ddb..9a5289ece2a23 100644 --- a/test/extensions/clusters/redis/redis_cluster_integration_test.cc +++ b/test/extensions/clusters/redis/redis_cluster_integration_test.cc @@ -149,9 +149,10 @@ class RedisClusterIntegrationTest : public testing::TestWithParammutable_clusters(0); - for (int j = 0; j < cluster_0->hosts_size(); ++j) { - if (cluster_0->mutable_hosts(j)->has_socket_address()) { - auto* host_socket_addr = cluster_0->mutable_hosts(j)->mutable_socket_address(); + for (int j = 0; j < cluster_0->hidden_envoy_deprecated_hosts_size(); ++j) { + if (cluster_0->mutable_hidden_envoy_deprecated_hosts(j)->has_socket_address()) { + auto* host_socket_addr = + cluster_0->mutable_hidden_envoy_deprecated_hosts(j)->mutable_socket_address(); RELEASE_ASSERT(fake_upstreams_.size() > upstream_idx, ""); host_socket_addr->set_address( fake_upstreams_[upstream_idx]->localAddress()->ip()->addressAsString()); diff --git a/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc b/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc index 1fb006d2acc44..78a4ef3e6d34f 100644 --- a/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc +++ b/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc @@ -59,9 +59,11 @@ class UdpProxyIntegrationTest : public testing::TestWithParammutable_clusters(0)->add_hosts(); - new_host->MergeFrom(bootstrap.static_resources().clusters(0).hosts(0)); + auto* new_host = bootstrap.mutable_static_resources() + ->mutable_clusters(0) + ->add_hidden_envoy_deprecated_hosts(); + new_host->MergeFrom( + bootstrap.static_resources().clusters(0).hidden_envoy_deprecated_hosts(0)); } }); } diff --git a/test/integration/custom_cluster_integration_test.cc b/test/integration/custom_cluster_integration_test.cc index d092870e5e41d..821afdde16406 100644 --- a/test/integration/custom_cluster_integration_test.cc +++ b/test/integration/custom_cluster_integration_test.cc @@ -28,7 +28,7 @@ class CustomClusterIntegrationTest : public testing::TestWithParammutable_clusters(0); - cluster_0->clear_hosts(); + cluster_0->clear_hidden_envoy_deprecated_hosts(); if (cluster_provided_lb_) { cluster_0->set_lb_policy(envoy::config::cluster::v3alpha::Cluster::CLUSTER_PROVIDED); diff --git a/test/integration/eds_integration_test.cc b/test/integration/eds_integration_test.cc index 120b110022c8a..495398fc9b704 100644 --- a/test/integration/eds_integration_test.cc +++ b/test/integration/eds_integration_test.cc @@ -113,7 +113,7 @@ class EdsIntegrationTest : public testing::TestWithParamCopyFrom( Protobuf::util::TimeUtil::MillisecondsToDuration(100)); cluster_.set_name("cluster_0"); - cluster_.mutable_hosts()->Clear(); + cluster_.mutable_hidden_envoy_deprecated_hosts()->Clear(); cluster_.set_type(envoy::config::cluster::v3alpha::Cluster::EDS); auto* eds_cluster_config = cluster_.mutable_eds_cluster_config(); eds_cluster_config->mutable_eds_config()->set_path(eds_helper_.eds_path()); diff --git a/test/integration/hds_integration_test.cc b/test/integration/hds_integration_test.cc index 61e8b7ba99c74..2bfdc6b2d1e0b 100644 --- a/test/integration/hds_integration_test.cc +++ b/test/integration/hds_integration_test.cc @@ -52,7 +52,7 @@ class HdsIntegrationTest : public testing::TestWithParamset_name("hds_cluster"); hds_cluster->mutable_http2_protocol_options(); auto* cluster_0 = bootstrap.mutable_static_resources()->mutable_clusters(0); - cluster_0->mutable_hosts()->Clear(); + cluster_0->mutable_hidden_envoy_deprecated_hosts()->Clear(); }); HttpIntegrationTest::initialize(); diff --git a/test/integration/http2_integration_test.cc b/test/integration/http2_integration_test.cc index c6a9fff5a80ee..d57ce372ac389 100644 --- a/test/integration/http2_integration_test.cc +++ b/test/integration/http2_integration_test.cc @@ -1201,10 +1201,10 @@ Http2RingHashIntegrationTest::Http2RingHashIntegrationTest() { config_helper_.addConfigModifier( [&](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) -> void { auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); - cluster->clear_hosts(); + cluster->clear_hidden_envoy_deprecated_hosts(); cluster->set_lb_policy(envoy::config::cluster::v3alpha::Cluster::RING_HASH); for (int i = 0; i < num_upstreams_; i++) { - auto* socket = cluster->add_hosts()->mutable_socket_address(); + auto* socket = cluster->add_hidden_envoy_deprecated_hosts()->mutable_socket_address(); socket->set_address(Network::Test::getLoopbackAddressString(version_)); } }); diff --git a/test/integration/http_subset_lb_integration_test.cc b/test/integration/http_subset_lb_integration_test.cc index 8c5d9e6af6c7b..354d0ddf15557 100644 --- a/test/integration/http_subset_lb_integration_test.cc +++ b/test/integration/http_subset_lb_integration_test.cc @@ -69,7 +69,7 @@ class HttpSubsetLbIntegrationTest // Create subsets based on type value of the "type" metadata. cluster->mutable_lb_subset_config()->add_subset_selectors()->add_keys(type_key_); - cluster->clear_hosts(); + cluster->clear_hidden_envoy_deprecated_hosts(); // Create a load assignment with num_hosts_ entries with metadata split evenly between // type=a and type=b. diff --git a/test/integration/load_stats_integration_test.cc b/test/integration/load_stats_integration_test.cc index 94e107d711e40..ede1a0b1441ac 100644 --- a/test/integration/load_stats_integration_test.cc +++ b/test/integration/load_stats_integration_test.cc @@ -127,7 +127,7 @@ class LoadStatsIntegrationTest : public testing::TestWithParamset_sub_zone(sub_zone_); // Switch predefined cluster_0 to EDS filesystem sourcing. auto* cluster_0 = bootstrap.mutable_static_resources()->mutable_clusters(0); - cluster_0->mutable_hosts()->Clear(); + cluster_0->mutable_hidden_envoy_deprecated_hosts()->Clear(); cluster_0->set_type(envoy::config::cluster::v3alpha::Cluster::EDS); auto* eds_cluster_config = cluster_0->mutable_eds_cluster_config(); eds_cluster_config->mutable_eds_config()->set_path(eds_helper_.eds_path()); diff --git a/test/integration/protocol_integration_test.cc b/test/integration/protocol_integration_test.cc index 1109fc28e3f9c..5b2f3b089326f 100644 --- a/test/integration/protocol_integration_test.cc +++ b/test/integration/protocol_integration_test.cc @@ -345,7 +345,7 @@ TEST_P(DownstreamProtocolIntegrationTest, RetryPriority) { auto cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); auto load_assignment = cluster->mutable_load_assignment(); load_assignment->set_cluster_name(cluster->name()); - const auto& host_address = cluster->hosts(0).socket_address().address(); + const auto& host_address = cluster->hidden_envoy_deprecated_hosts(0).socket_address().address(); for (int i = 0; i < 2; ++i) { auto locality = load_assignment->add_endpoints(); @@ -360,7 +360,7 @@ TEST_P(DownstreamProtocolIntegrationTest, RetryPriority) { 0); } - cluster->clear_hosts(); + cluster->clear_hidden_envoy_deprecated_hosts(); }); fake_upstreams_count_ = 2; @@ -417,8 +417,10 @@ TEST_P(DownstreamProtocolIntegrationTest, RetryHostPredicateFilter) { // We want to work with a cluster with two hosts. config_helper_.addConfigModifier([](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) { - auto* new_host = bootstrap.mutable_static_resources()->mutable_clusters(0)->add_hosts(); - new_host->MergeFrom(bootstrap.static_resources().clusters(0).hosts(0)); + auto* new_host = bootstrap.mutable_static_resources() + ->mutable_clusters(0) + ->add_hidden_envoy_deprecated_hosts(); + new_host->MergeFrom(bootstrap.static_resources().clusters(0).hidden_envoy_deprecated_hosts(0)); }); fake_upstreams_count_ = 2; initialize(); diff --git a/test/integration/proxy_proto_integration_test.cc b/test/integration/proxy_proto_integration_test.cc index 45fe46936ba6b..090fce650c82d 100644 --- a/test/integration/proxy_proto_integration_test.cc +++ b/test/integration/proxy_proto_integration_test.cc @@ -99,7 +99,7 @@ TEST_P(ProxyProtoIntegrationTest, DEPRECATED_FEATURE_TEST(OriginalDst)) { config_helper_.addConfigModifier( [&](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) -> void { auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); - cluster->mutable_hosts()->Clear(); + cluster->mutable_hidden_envoy_deprecated_hosts()->Clear(); cluster->set_type(envoy::config::cluster::v3alpha::Cluster::ORIGINAL_DST); cluster->set_lb_policy( envoy::config::cluster::v3alpha::Cluster::hidden_envoy_deprecated_ORIGINAL_DST_LB); @@ -131,7 +131,7 @@ TEST_P(ProxyProtoIntegrationTest, ClusterProvided) { config_helper_.addConfigModifier( [&](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) -> void { auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); - cluster->mutable_hosts()->Clear(); + cluster->mutable_hidden_envoy_deprecated_hosts()->Clear(); cluster->set_type(envoy::config::cluster::v3alpha::Cluster::ORIGINAL_DST); cluster->set_lb_policy(envoy::config::cluster::v3alpha::Cluster::CLUSTER_PROVIDED); }); diff --git a/test/integration/stats_integration_test.cc b/test/integration/stats_integration_test.cc index 28a86a8fc43b3..c882bf5885a0b 100644 --- a/test/integration/stats_integration_test.cc +++ b/test/integration/stats_integration_test.cc @@ -193,7 +193,7 @@ class ClusterMemoryTestHelper : public BaseIntegrationTest { for (int i = 0; i < num_clusters; ++i) { auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(i); for (int j = 0; j < num_hosts; ++j) { - auto* host = cluster->add_hosts(); + auto* host = cluster->add_hidden_envoy_deprecated_hosts(); auto* socket_address = host->mutable_socket_address(); socket_address->set_protocol(envoy::config::core::v3alpha::SocketAddress::TCP); socket_address->set_address("0.0.0.0"); diff --git a/test/integration/transport_socket_match_integration_test.cc b/test/integration/transport_socket_match_integration_test.cc index db087bc076a28..23b9273b9d265 100644 --- a/test/integration/transport_socket_match_integration_test.cc +++ b/test/integration/transport_socket_match_integration_test.cc @@ -52,7 +52,7 @@ name: "tls_socket" TestUtility::loadFromYaml(match_yaml, *transport_socket_match); } // Setup the client Envoy TLS config. - cluster->clear_hosts(); + cluster->clear_hidden_envoy_deprecated_hosts(); auto* load_assignment = cluster->mutable_load_assignment(); load_assignment->set_cluster_name(cluster->name()); auto* endpoints = load_assignment->add_endpoints(); diff --git a/test/integration/uds_integration_test.h b/test/integration/uds_integration_test.h index 82432b29c74ef..5766c0e87472f 100644 --- a/test/integration/uds_integration_test.h +++ b/test/integration/uds_integration_test.h @@ -34,9 +34,9 @@ class UdsUpstreamIntegrationTest auto* static_resources = bootstrap.mutable_static_resources(); for (int i = 0; i < static_resources->clusters_size(); ++i) { auto* cluster = static_resources->mutable_clusters(i); - for (int j = 0; j < cluster->hosts_size(); ++j) { - cluster->mutable_hosts(j)->clear_socket_address(); - cluster->mutable_hosts(j)->mutable_pipe()->set_path( + for (int j = 0; j < cluster->hidden_envoy_deprecated_hosts_size(); ++j) { + cluster->mutable_hidden_envoy_deprecated_hosts(j)->clear_socket_address(); + cluster->mutable_hidden_envoy_deprecated_hosts(j)->mutable_pipe()->set_path( TestEnvironment::unixDomainSocketPath("udstest.1.sock", abstract_namespace_)); } } diff --git a/test/server/server_fuzz_test.cc b/test/server/server_fuzz_test.cc index c00876caad6b2..a923b93078430 100644 --- a/test/server/server_fuzz_test.cc +++ b/test/server/server_fuzz_test.cc @@ -58,7 +58,7 @@ makeHermeticPathsAndPorts(Fuzz::PerTestEnvironment& test_env, // Tracked at https://github.com/envoyproxy/envoy/issues/9513. health_check.mutable_http_health_check()->clear_codec_client_type(); } - for (auto& host : *cluster.mutable_hosts()) { + for (auto& host : *cluster.mutable_hidden_envoy_deprecated_hosts()) { makePortHermetic(test_env, host); } } From f349baafe8c48569a6f801afaa176622ba864668 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Mon, 13 Jan 2020 21:31:16 -0500 Subject: [PATCH 2/7] All tests pass with --define deprecated_features=disabled. Signed-off-by: Harvey Tuch --- examples/grpc-bridge/server/envoy-proxy.yaml | 13 ++-- source/common/config/version_converter.cc | 2 +- test/common/config/version_converter_test.cc | 4 +- test/common/upstream/upstream_impl_test.cc | 2 +- .../google_com_proxy_port_0.v2.yaml | 7 +- test/config/integration/server.yaml | 65 +++++++++++------ .../integration/server_unix_listener.yaml | 13 ++-- test/config/utility.cc | 70 ++++++++++--------- .../aggregate/cluster_integration_test.cc | 13 ++-- .../redis/redis_cluster_integration_test.cc | 49 ++++++++----- .../udp_proxy/udp_proxy_integration_test.cc | 11 ++- test/integration/ads_integration.h | 13 ++-- test/integration/hds_integration_test.cc | 2 +- test/integration/header_integration_test.cc | 26 ++++--- test/integration/http2_integration_test.cc | 11 ++- .../http_subset_lb_integration_test.cc | 2 +- test/integration/protocol_integration_test.cc | 28 +++++--- .../proxy_proto_integration_test.cc | 4 +- test/integration/rtds_integration_test.cc | 26 ++++--- test/integration/stats_integration_test.cc | 11 ++- ...transport_socket_match_integration_test.cc | 2 +- test/integration/uds_integration_test.h | 15 ++-- test/integration/vhds_integration_test.cc | 26 ++++--- .../listener_manager_impl_quic_only_test.cc | 6 +- 24 files changed, 273 insertions(+), 148 deletions(-) diff --git a/examples/grpc-bridge/server/envoy-proxy.yaml b/examples/grpc-bridge/server/envoy-proxy.yaml index fea3864928368..de25aa91f8227 100644 --- a/examples/grpc-bridge/server/envoy-proxy.yaml +++ b/examples/grpc-bridge/server/envoy-proxy.yaml @@ -37,10 +37,15 @@ static_resources: type: strict_dns lb_policy: round_robin http2_protocol_options: {} - hosts: - - socket_address: - address: kv-backend-service - port_value: 8081 + load_assignment: + cluster_name: backend_grpc_service + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: kv-backend-service + port_value: 8081 admin: access_log_path: "/tmp/admin_access.log" diff --git a/source/common/config/version_converter.cc b/source/common/config/version_converter.cc index 787ab1084bf69..af7caa972e175 100644 --- a/source/common/config/version_converter.cc +++ b/source/common/config/version_converter.cc @@ -115,7 +115,7 @@ void annotateWithOriginalType(const Protobuf::Descriptor& prev_descriptor, // ClusterManagerImpl with type erasure, but protobuf doesn't free up memory // as expected, we probably need some arena level trick to address this. if (prev_descriptor.full_name() == "envoy.api.v2.Cluster" && - (field.name() == "hosts" || field.name() == "load_assignment")) { + (field.name() == "hidden_envoy_deprecated_hosts" || field.name() == "load_assignment")) { // This will cause the sub-message visit to abort early. return field.message_type(); } diff --git a/test/common/config/version_converter_test.cc b/test/common/config/version_converter_test.cc index 35de12e06a087..c6d42053a37eb 100644 --- a/test/common/config/version_converter_test.cc +++ b/test/common/config/version_converter_test.cc @@ -41,8 +41,8 @@ TEST(VersionConverterTest, Upgrade) { VersionConverter::upgrade(source, dst); // Verify fields in v3 Cluster. EXPECT_TRUE(hasOriginalTypeInformation(dst)); - EXPECT_FALSE(dst.hosts().empty()); - EXPECT_FALSE(hasOriginalTypeInformation(dst.hosts(0))); + EXPECT_FALSE(dst.hidden_envoy_deprecated_hosts().empty()); + EXPECT_FALSE(hasOriginalTypeInformation(dst.hidden_envoy_deprecated_hosts(0))); EXPECT_EQ("bar", dst.load_assignment().cluster_name()); EXPECT_FALSE(hasOriginalTypeInformation(dst.load_assignment())); EXPECT_EQ("foo", dst.eds_cluster_config().service_name()); diff --git a/test/common/upstream/upstream_impl_test.cc b/test/common/upstream/upstream_impl_test.cc index b82920e2a676d..7619c1192777f 100644 --- a/test/common/upstream/upstream_impl_test.cc +++ b/test/common/upstream/upstream_impl_test.cc @@ -1566,7 +1566,7 @@ TEST_F(StaticClusterImplTest, UnsupportedLBType) { connect_timeout: 0.25s type: static lb_policy: fakelbtype - hosts: + hidden_envoy_deprecated_hosts: - { socket_address: { address: 192.168.1.1, port_value: 22 }} - { socket_address: { address: 192.168.1.2, port_value: 44 }} )EOF"; diff --git a/test/config/integration/google_com_proxy_port_0.v2.yaml b/test/config/integration/google_com_proxy_port_0.v2.yaml index 67f4e54d29228..f6f33aa33a915 100644 --- a/test/config/integration/google_com_proxy_port_0.v2.yaml +++ b/test/config/integration/google_com_proxy_port_0.v2.yaml @@ -34,4 +34,9 @@ static_resources: # Comment out the following line to test on v6 networks dns_lookup_family: {{ dns_lookup_family }} lb_policy: ROUND_ROBIN - hosts: [{ socket_address: { address: google.com, port_value: 443 }}] + load_assignment: + cluster_name: service_google + endpoints: + - lb_endpoints: + - endpoint: + address: { socket_address: { address: google.com, port_value: 443 }} diff --git a/test/config/integration/server.yaml b/test/config/integration/server.yaml index 3813fa137bdfd..15456cc95b452 100644 --- a/test/config/integration/server.yaml +++ b/test/config/integration/server.yaml @@ -87,43 +87,68 @@ static_resources: clusters: - name: cluster_1 connect_timeout: 5s - hosts: - - socket_address: - address: {{ ip_loopback_address }} - port_value: {{ upstream_0 }} + load_assignment: + cluster_name: cluster_1 + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: {{ ip_loopback_address }} + port_value: {{ upstream_0 }} dns_lookup_family: "{{ dns_lookup_family }}" - name: cluster_2 type: STRICT_DNS connect_timeout: 5s - hosts: - - socket_address: - address: localhost - port_value: {{ upstream_1 }} + load_assignment: + cluster_name: cluster_2 + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: localhost + port_value: {{ upstream_1 }} dns_lookup_family: "{{ dns_lookup_family }}" - name: cluster_3 connect_timeout: 5s per_connection_buffer_limit_bytes: 1024 - hosts: - - socket_address: - address: {{ ip_loopback_address }} - port_value: {{ upstream_0 }} + load_assignment: + cluster_name: cluster_3 + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: {{ ip_loopback_address }} + port_value: {{ upstream_0 }} dns_lookup_family: "{{ dns_lookup_family }}" - name: statsd type: STRICT_DNS connect_timeout: 5s - hosts: - - socket_address: - address: localhost - port_value: 4 + load_assignment: + cluster_name: statsd + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: localhost + port_value: 4 dns_lookup_family: "{{ dns_lookup_family }}" - name: redis type: STRICT_DNS connect_timeout: 5s lb_policy: RING_HASH - hosts: - - socket_address: - address: localhost - port_value: 4 + load_assignment: + cluster_name: redis + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: localhost + port_value: 4 dns_lookup_family: "{{ dns_lookup_family }}" outlier_detection: {} dynamic_resources: {} diff --git a/test/config/integration/server_unix_listener.yaml b/test/config/integration/server_unix_listener.yaml index 72c4e98597f62..56ce466da30c3 100644 --- a/test/config/integration/server_unix_listener.yaml +++ b/test/config/integration/server_unix_listener.yaml @@ -26,10 +26,15 @@ static_resources: clusters: - name: cluster_0 connect_timeout: 5s - hosts: - - socket_address: - address: "{{ ip_loopback_address }}" - port_value: 0 + load_assignment: + cluster_name: cluster_0 + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: "{{ ip_loopback_address }}" + port_value: 0 dns_lookup_family: V4_ONLY cluster_manager: {} watchdog: {} diff --git a/test/config/utility.cc b/test/config/utility.cc index 5a6014a31b5c5..48e845667e262 100644 --- a/test/config/utility.cc +++ b/test/config/utility.cc @@ -51,10 +51,15 @@ const std::string ConfigHelper::BASE_CONFIG = R"EOF( inline_string: "DUMMY_INLINE_BYTES" clusters: name: cluster_0 - hosts: - socket_address: - address: 127.0.0.1 - port_value: 0 + load_assignment: + cluster_name: cluster_0 + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 0 listeners: name: listener_0 address: @@ -73,10 +78,15 @@ const std::string ConfigHelper::BASE_UDP_LISTENER_CONFIG = R"EOF( static_resources: clusters: name: cluster_0 - hosts: - socket_address: - address: 127.0.0.1 - port_value: 0 + load_assignment: + cluster_name: cluster_0 + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 0 listeners: name: listener_0 address: @@ -231,10 +241,15 @@ std::string ConfigHelper::discoveredClustersBootstrap(const std::string& api_typ clusters: - name: my_cds_cluster http2_protocol_options: {{}} - hosts: - socket_address: - address: 127.0.0.1 - port_value: 0 + load_assignment: + cluster_name: my_cds_cluster + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 0 listeners: name: http address: @@ -286,10 +301,15 @@ std::string ConfigHelper::adsBootstrap(const std::string& api_type) { connect_timeout: seconds: 5 type: STATIC - hosts: - socket_address: - address: 127.0.0.1 - port_value: 0 + load_assignment: + cluster_name: dummy_cluster + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 0 lb_policy: ROUND_ROBIN http2_protocol_options: {{}} admin: @@ -348,15 +368,6 @@ ConfigHelper::ConfigHelper(const Network::Address::IpVersion version, Api::Api& for (int i = 0; i < static_resources->clusters_size(); ++i) { auto* cluster = static_resources->mutable_clusters(i); - if (!cluster->hidden_envoy_deprecated_hosts().empty()) { - for (int j = 0; j < cluster->hidden_envoy_deprecated_hosts().size(); j++) { - if (cluster->mutable_hidden_envoy_deprecated_hosts(j)->has_socket_address()) { - auto host_socket_addr = - cluster->mutable_hidden_envoy_deprecated_hosts(j)->mutable_socket_address(); - host_socket_addr->set_address(Network::Test::getLoopbackAddressString(version)); - } - } - } for (int j = 0; j < cluster->load_assignment().endpoints_size(); ++j) { auto locality_lb = cluster->mutable_load_assignment()->mutable_endpoints(j); for (int k = 0; k < locality_lb->lb_endpoints_size(); ++k) { @@ -418,15 +429,6 @@ void ConfigHelper::finalize(const std::vector& ports) { } else if (cluster->has_cluster_type()) { custom_cluster = true; } else { - for (int j = 0; j < cluster->hidden_envoy_deprecated_hosts_size(); ++j) { - if (cluster->mutable_hidden_envoy_deprecated_hosts(j)->has_socket_address()) { - auto* host_socket_addr = - cluster->mutable_hidden_envoy_deprecated_hosts(j)->mutable_socket_address(); - RELEASE_ASSERT(ports.size() > port_idx, ""); - host_socket_addr->set_port_value(ports[port_idx++]); - } - } - // Assign ports to statically defined load_assignment hosts. for (int j = 0; j < cluster->load_assignment().endpoints_size(); ++j) { auto locality_lb = cluster->mutable_load_assignment()->mutable_endpoints(j); diff --git a/test/extensions/clusters/aggregate/cluster_integration_test.cc b/test/extensions/clusters/aggregate/cluster_integration_test.cc index 49377004908db..5d416d4423ffb 100644 --- a/test/extensions/clusters/aggregate/cluster_integration_test.cc +++ b/test/extensions/clusters/aggregate/cluster_integration_test.cc @@ -49,10 +49,15 @@ const std::string& config() { clusters: - name: my_cds_cluster http2_protocol_options: {} - hosts: - socket_address: - address: 127.0.0.1 - port_value: 0 + load_assignment: + cluster_name: my_cds_cluster + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 0 - name: aggregate_cluster connect_timeout: 0.25s lb_policy: CLUSTER_PROVIDED diff --git a/test/extensions/clusters/redis/redis_cluster_integration_test.cc b/test/extensions/clusters/redis/redis_cluster_integration_test.cc index 9a5289ece2a23..fd31482e554f8 100644 --- a/test/extensions/clusters/redis/redis_cluster_integration_test.cc +++ b/test/extensions/clusters/redis/redis_cluster_integration_test.cc @@ -52,10 +52,15 @@ const std::string& clusterConfig() { clusters: - name: cluster_0 lb_policy: CLUSTER_PROVIDED - hosts: - - socket_address: - address: 127.0.0.1 - port_value: 0 + load_assignment: + cluster_name: cluster_0 + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 0 cluster_type: name: envoy.clusters.redis typed_config: @@ -77,10 +82,15 @@ const std::string& testConfigWithRefresh() { clusters: - name: cluster_0 lb_policy: CLUSTER_PROVIDED - hosts: - - socket_address: - address: 127.0.0.1 - port_value: 0 + load_assignment: + cluster_name: cluser_0 + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 0 cluster_type: name: envoy.clusters.redis typed_config: @@ -148,16 +158,19 @@ class RedisClusterIntegrationTest : public testing::TestWithParammutable_clusters(0); - - for (int j = 0; j < cluster_0->hidden_envoy_deprecated_hosts_size(); ++j) { - if (cluster_0->mutable_hidden_envoy_deprecated_hosts(j)->has_socket_address()) { - auto* host_socket_addr = - cluster_0->mutable_hidden_envoy_deprecated_hosts(j)->mutable_socket_address(); - RELEASE_ASSERT(fake_upstreams_.size() > upstream_idx, ""); - host_socket_addr->set_address( - fake_upstreams_[upstream_idx]->localAddress()->ip()->addressAsString()); - host_socket_addr->set_port_value( - fake_upstreams_[upstream_idx++]->localAddress()->ip()->port()); + for (int j = 0; j < cluster_0->load_assignment().endpoints_size(); ++j) { + auto locality_lb = cluster_0->mutable_load_assignment()->mutable_endpoints(j); + for (int k = 0; k < locality_lb->lb_endpoints_size(); ++k) { + auto lb_endpoint = locality_lb->mutable_lb_endpoints(k); + if (lb_endpoint->endpoint().address().has_socket_address()) { + auto* host_socket_addr = + lb_endpoint->mutable_endpoint()->mutable_address()->mutable_socket_address(); + RELEASE_ASSERT(fake_upstreams_.size() > upstream_idx, ""); + host_socket_addr->set_address( + fake_upstreams_[upstream_idx]->localAddress()->ip()->addressAsString()); + host_socket_addr->set_port_value( + fake_upstreams_[upstream_idx++]->localAddress()->ip()->port()); + } } } }); diff --git a/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc b/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc index 78a4ef3e6d34f..43d4887cd2593 100644 --- a/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc +++ b/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc @@ -61,9 +61,14 @@ class UdpProxyIntegrationTest : public testing::TestWithParammutable_clusters(0) - ->add_hidden_envoy_deprecated_hosts(); - new_host->MergeFrom( - bootstrap.static_resources().clusters(0).hidden_envoy_deprecated_hosts(0)); + ->mutable_load_assignment() + ->mutable_endpoints(0) + ->add_lb_endpoints(); + new_host->MergeFrom(bootstrap.static_resources() + .clusters(0) + .load_assignment() + .endpoints(0) + .lb_endpoints(0)); } }); } diff --git a/test/integration/ads_integration.h b/test/integration/ads_integration.h index cf5e76ef10a81..f7cc9d4c29ab9 100644 --- a/test/integration/ads_integration.h +++ b/test/integration/ads_integration.h @@ -32,10 +32,15 @@ static std::string AdsIntegrationConfig(const std::string& api_type) { connect_timeout: seconds: 5 type: STATIC - hosts: - socket_address: - address: 127.0.0.1 - port_value: 0 + load_assignment: + cluster_name: dummy_cluster + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 0 lb_policy: ROUND_ROBIN http2_protocol_options: {{}} admin: diff --git a/test/integration/hds_integration_test.cc b/test/integration/hds_integration_test.cc index 2bfdc6b2d1e0b..db8bd671841dc 100644 --- a/test/integration/hds_integration_test.cc +++ b/test/integration/hds_integration_test.cc @@ -52,7 +52,7 @@ class HdsIntegrationTest : public testing::TestWithParamset_name("hds_cluster"); hds_cluster->mutable_http2_protocol_options(); auto* cluster_0 = bootstrap.mutable_static_resources()->mutable_clusters(0); - cluster_0->mutable_hidden_envoy_deprecated_hosts()->Clear(); + cluster_0->clear_load_assignment(); }); HttpIntegrationTest::initialize(); diff --git a/test/integration/header_integration_test.cc b/test/integration/header_integration_test.cc index 155ddc6c7de46..b2a3e4e3c0461 100644 --- a/test/integration/header_integration_test.cc +++ b/test/integration/header_integration_test.cc @@ -241,10 +241,15 @@ class HeaderIntegrationTest name: unused-cluster type: STATIC lb_policy: ROUND_ROBIN - hosts: - - socket_address: - address: {} - port_value: 0 + load_assignment: + cluster_name: unused-cluster + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: {} + port_value: 0 )EOF", Network::Test::getLoopbackAddressString(version_)))); @@ -256,10 +261,15 @@ class HeaderIntegrationTest lb_policy: ROUND_ROBIN http2_protocol_options: {{}} connect_timeout: 5s - hosts: - - socket_address: - address: {} - port_value: 0 + load_assignment: + cluster_name: eds-cluster + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: {} + port_value: 0 )EOF", Network::Test::getLoopbackAddressString(version_)))); }); diff --git a/test/integration/http2_integration_test.cc b/test/integration/http2_integration_test.cc index d57ce372ac389..e02d34eeedc27 100644 --- a/test/integration/http2_integration_test.cc +++ b/test/integration/http2_integration_test.cc @@ -1201,10 +1201,17 @@ Http2RingHashIntegrationTest::Http2RingHashIntegrationTest() { config_helper_.addConfigModifier( [&](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) -> void { auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); - cluster->clear_hidden_envoy_deprecated_hosts(); + cluster->clear_load_assignment(); + cluster->mutable_load_assignment()->add_endpoints(); + cluster->mutable_load_assignment()->set_cluster_name(cluster->name()); cluster->set_lb_policy(envoy::config::cluster::v3alpha::Cluster::RING_HASH); for (int i = 0; i < num_upstreams_; i++) { - auto* socket = cluster->add_hidden_envoy_deprecated_hosts()->mutable_socket_address(); + auto* socket = cluster->mutable_load_assignment() + ->mutable_endpoints(0) + ->add_lb_endpoints() + ->mutable_endpoint() + ->mutable_address() + ->mutable_socket_address(); socket->set_address(Network::Test::getLoopbackAddressString(version_)); } }); diff --git a/test/integration/http_subset_lb_integration_test.cc b/test/integration/http_subset_lb_integration_test.cc index 354d0ddf15557..4874e1dba834c 100644 --- a/test/integration/http_subset_lb_integration_test.cc +++ b/test/integration/http_subset_lb_integration_test.cc @@ -69,7 +69,7 @@ class HttpSubsetLbIntegrationTest // Create subsets based on type value of the "type" metadata. cluster->mutable_lb_subset_config()->add_subset_selectors()->add_keys(type_key_); - cluster->clear_hidden_envoy_deprecated_hosts(); + cluster->clear_load_assignment(); // Create a load assignment with num_hosts_ entries with metadata split evenly between // type=a and type=b. diff --git a/test/integration/protocol_integration_test.cc b/test/integration/protocol_integration_test.cc index 5b2f3b089326f..2c344709f4ab9 100644 --- a/test/integration/protocol_integration_test.cc +++ b/test/integration/protocol_integration_test.cc @@ -339,13 +339,19 @@ TEST_P(DownstreamProtocolIntegrationTest, RetryPriority) { auto retry_policy = host.mutable_routes(0)->mutable_route()->mutable_retry_policy(); retry_policy->mutable_retry_priority()->set_name(factory.name()); config_helper_.addVirtualHost(host); - - // Use load assignments instead of static hosts. Necessary in order to use priorities. + // We want to work with a cluster with two hosts. config_helper_.addConfigModifier([](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) { - auto cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); - auto load_assignment = cluster->mutable_load_assignment(); + auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); + const std::string host_address = cluster->load_assignment() + .endpoints(0) + .lb_endpoints(0) + .endpoint() + .address() + .socket_address() + .address(); + cluster->clear_load_assignment(); + auto* load_assignment = cluster->mutable_load_assignment(); load_assignment->set_cluster_name(cluster->name()); - const auto& host_address = cluster->hidden_envoy_deprecated_hosts(0).socket_address().address(); for (int i = 0; i < 2; ++i) { auto locality = load_assignment->add_endpoints(); @@ -353,16 +359,13 @@ TEST_P(DownstreamProtocolIntegrationTest, RetryPriority) { locality->mutable_locality()->set_region("region"); locality->mutable_locality()->set_zone("zone"); locality->mutable_locality()->set_sub_zone("sub_zone" + std::to_string(i)); - auto lb_endpoint = locality->add_lb_endpoints(); + auto* lb_endpoint = locality->add_lb_endpoints(); lb_endpoint->mutable_endpoint()->mutable_address()->mutable_socket_address()->set_address( host_address); lb_endpoint->mutable_endpoint()->mutable_address()->mutable_socket_address()->set_port_value( 0); } - - cluster->clear_hidden_envoy_deprecated_hosts(); }); - fake_upstreams_count_ = 2; initialize(); codec_client_ = makeHttpConnection(lookupPort("http")); @@ -419,8 +422,11 @@ TEST_P(DownstreamProtocolIntegrationTest, RetryHostPredicateFilter) { config_helper_.addConfigModifier([](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) { auto* new_host = bootstrap.mutable_static_resources() ->mutable_clusters(0) - ->add_hidden_envoy_deprecated_hosts(); - new_host->MergeFrom(bootstrap.static_resources().clusters(0).hidden_envoy_deprecated_hosts(0)); + ->mutable_load_assignment() + ->mutable_endpoints(0) + ->add_lb_endpoints(); + new_host->MergeFrom( + bootstrap.static_resources().clusters(0).load_assignment().endpoints(0).lb_endpoints(0)); }); fake_upstreams_count_ = 2; initialize(); diff --git a/test/integration/proxy_proto_integration_test.cc b/test/integration/proxy_proto_integration_test.cc index 090fce650c82d..84cb1cd01f9ec 100644 --- a/test/integration/proxy_proto_integration_test.cc +++ b/test/integration/proxy_proto_integration_test.cc @@ -99,7 +99,7 @@ TEST_P(ProxyProtoIntegrationTest, DEPRECATED_FEATURE_TEST(OriginalDst)) { config_helper_.addConfigModifier( [&](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) -> void { auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); - cluster->mutable_hidden_envoy_deprecated_hosts()->Clear(); + cluster->clear_load_assignment(); cluster->set_type(envoy::config::cluster::v3alpha::Cluster::ORIGINAL_DST); cluster->set_lb_policy( envoy::config::cluster::v3alpha::Cluster::hidden_envoy_deprecated_ORIGINAL_DST_LB); @@ -131,7 +131,7 @@ TEST_P(ProxyProtoIntegrationTest, ClusterProvided) { config_helper_.addConfigModifier( [&](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) -> void { auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); - cluster->mutable_hidden_envoy_deprecated_hosts()->Clear(); + cluster->clear_load_assignment(); cluster->set_type(envoy::config::cluster::v3alpha::Cluster::ORIGINAL_DST); cluster->set_lb_policy(envoy::config::cluster::v3alpha::Cluster::CLUSTER_PROVIDED); }); diff --git a/test/integration/rtds_integration_test.cc b/test/integration/rtds_integration_test.cc index 4921d821c76c1..30000e4d6686a 100644 --- a/test/integration/rtds_integration_test.cc +++ b/test/integration/rtds_integration_test.cc @@ -15,16 +15,26 @@ std::string tdsBootstrapConfig(absl::string_view api_type) { static_resources: clusters: - name: dummy_cluster - hosts: - socket_address: - address: 127.0.0.1 - port_value: 0 + load_assignment: + cluster_name: dummy_cluster + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 0 - name: rtds_cluster http2_protocol_options: {{}} - hosts: - socket_address: - address: 127.0.0.1 - port_value: 0 + load_assignment: + cluster_name: rtds_cluster + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 0 layered_runtime: layers: - name: some_static_layer diff --git a/test/integration/stats_integration_test.cc b/test/integration/stats_integration_test.cc index c882bf5885a0b..e392316c30df7 100644 --- a/test/integration/stats_integration_test.cc +++ b/test/integration/stats_integration_test.cc @@ -193,7 +193,11 @@ class ClusterMemoryTestHelper : public BaseIntegrationTest { for (int i = 0; i < num_clusters; ++i) { auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(i); for (int j = 0; j < num_hosts; ++j) { - auto* host = cluster->add_hidden_envoy_deprecated_hosts(); + auto* host = cluster->mutable_load_assignment() + ->mutable_endpoints(0) + ->add_lb_endpoints() + ->mutable_endpoint() + ->mutable_address(); auto* socket_address = host->mutable_socket_address(); socket_address->set_protocol(envoy::config::core::v3alpha::SocketAddress::TCP); socket_address->set_address("0.0.0.0"); @@ -369,6 +373,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeHostSizeWithStats) { // 2019/11/01 8859 1299 1315 build: switch to libc++ by default // 2019/11/12 8998 1299 1350 test: adjust memory limit for macOS // 2019/11/15 9040 1283 1350 build: update protobuf to 3.10.1 + // 2020/01/13 9663 1619 1619 api: deprecate hosts in Cluster. // Note: when adjusting this value: EXPECT_MEMORY_EQ is active only in CI // 'release' builds, where we control the platform and tool-chain. So you @@ -378,8 +383,8 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeHostSizeWithStats) { // If you encounter a failure here, please see // https://github.com/envoyproxy/envoy/blob/master/source/docs/stats.md#stats-memory-tests // for details on how to fix. - EXPECT_MEMORY_EQ(m_per_host, 1283); - EXPECT_MEMORY_LE(m_per_host, 1350); + EXPECT_MEMORY_EQ(m_per_host, 1619); + EXPECT_MEMORY_LE(m_per_host, 1619); } } // namespace diff --git a/test/integration/transport_socket_match_integration_test.cc b/test/integration/transport_socket_match_integration_test.cc index 23b9273b9d265..9b80a75e5301c 100644 --- a/test/integration/transport_socket_match_integration_test.cc +++ b/test/integration/transport_socket_match_integration_test.cc @@ -52,7 +52,7 @@ name: "tls_socket" TestUtility::loadFromYaml(match_yaml, *transport_socket_match); } // Setup the client Envoy TLS config. - cluster->clear_hidden_envoy_deprecated_hosts(); + cluster->clear_load_assignment(); auto* load_assignment = cluster->mutable_load_assignment(); load_assignment->set_cluster_name(cluster->name()); auto* endpoints = load_assignment->add_endpoints(); diff --git a/test/integration/uds_integration_test.h b/test/integration/uds_integration_test.h index 5766c0e87472f..b911e5a704ba8 100644 --- a/test/integration/uds_integration_test.h +++ b/test/integration/uds_integration_test.h @@ -34,10 +34,17 @@ class UdsUpstreamIntegrationTest auto* static_resources = bootstrap.mutable_static_resources(); for (int i = 0; i < static_resources->clusters_size(); ++i) { auto* cluster = static_resources->mutable_clusters(i); - for (int j = 0; j < cluster->hidden_envoy_deprecated_hosts_size(); ++j) { - cluster->mutable_hidden_envoy_deprecated_hosts(j)->clear_socket_address(); - cluster->mutable_hidden_envoy_deprecated_hosts(j)->mutable_pipe()->set_path( - TestEnvironment::unixDomainSocketPath("udstest.1.sock", abstract_namespace_)); + for (int j = 0; j < cluster->load_assignment().endpoints_size(); ++j) { + auto locality_lb = cluster->mutable_load_assignment()->mutable_endpoints(j); + for (int k = 0; k < locality_lb->lb_endpoints_size(); ++k) { + auto lb_endpoint = locality_lb->mutable_lb_endpoints(k); + if (lb_endpoint->endpoint().address().has_socket_address()) { + auto* address = lb_endpoint->mutable_endpoint()->mutable_address(); + address->clear_socket_address(); + address->mutable_pipe()->set_path( + TestEnvironment::unixDomainSocketPath("udstest.1.sock", abstract_namespace_)); + } + } } } }); diff --git a/test/integration/vhds_integration_test.cc b/test/integration/vhds_integration_test.cc index e8cdeb421489c..091ac8790dc2b 100644 --- a/test/integration/vhds_integration_test.cc +++ b/test/integration/vhds_integration_test.cc @@ -36,17 +36,27 @@ const char Config[] = R"EOF( - name: xds_cluster type: STATIC http2_protocol_options: {} - hosts: - socket_address: - address: 127.0.0.1 - port_value: 0 + load_assignment: + cluster_name: xds_cluster + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 0 - name: my_service type: STATIC http2_protocol_options: {} - hosts: - socket_address: - address: 127.0.0.1 - port_value: 0 + load_assignment: + cluster_name: my_service + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: 127.0.0.1 + port_value: 0 listeners: - name: http address: diff --git a/test/server/listener_manager_impl_quic_only_test.cc b/test/server/listener_manager_impl_quic_only_test.cc index 5524b3e9ec516..f9baefd1018c6 100644 --- a/test/server/listener_manager_impl_quic_only_test.cc +++ b/test/server/listener_manager_impl_quic_only_test.cc @@ -36,9 +36,9 @@ TEST_F(ListenerManagerImplQuicOnlyTest, QuicListenerFactoryAndSslContext) { validation_context: trusted_ca: filename: "{{ test_rundir }}/test/extensions/transport_sockets/tls/test_data/ca_cert.pem" - verify_subject_alt_name: - - localhost - - 127.0.0.1 + match_subject_alt_names: + - exact: localhost + - exact: 127.0.0.1 reuse_port: true udp_listener_config: udp_listener_name: "quiche_quic_listener" From e397703a1442dc6a5535cdb9144eb9da68fce1f2 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Tue, 14 Jan 2020 08:35:32 -0500 Subject: [PATCH 3/7] Bump upper bound on host memory for Mac. Signed-off-by: Harvey Tuch --- test/integration/stats_integration_test.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/integration/stats_integration_test.cc b/test/integration/stats_integration_test.cc index e392316c30df7..b60ac7e34f9ff 100644 --- a/test/integration/stats_integration_test.cc +++ b/test/integration/stats_integration_test.cc @@ -373,7 +373,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeHostSizeWithStats) { // 2019/11/01 8859 1299 1315 build: switch to libc++ by default // 2019/11/12 8998 1299 1350 test: adjust memory limit for macOS // 2019/11/15 9040 1283 1350 build: update protobuf to 3.10.1 - // 2020/01/13 9663 1619 1619 api: deprecate hosts in Cluster. + // 2020/01/13 9663 1619 1655 api: deprecate hosts in Cluster. // Note: when adjusting this value: EXPECT_MEMORY_EQ is active only in CI // 'release' builds, where we control the platform and tool-chain. So you @@ -384,7 +384,7 @@ TEST_P(ClusterMemoryTestRunner, MemoryLargeHostSizeWithStats) { // https://github.com/envoyproxy/envoy/blob/master/source/docs/stats.md#stats-memory-tests // for details on how to fix. EXPECT_MEMORY_EQ(m_per_host, 1619); - EXPECT_MEMORY_LE(m_per_host, 1619); + EXPECT_MEMORY_LE(m_per_host, 1655); } } // namespace From 818522e6e8dee39b56f16570a45a996039fc7997 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Tue, 14 Jan 2020 17:18:19 -0500 Subject: [PATCH 4/7] Review feedback. Signed-off-by: Harvey Tuch --- .../upstream/health_discovery_service.cc | 8 +++-- test/common/upstream/upstream_impl_test.cc | 11 ++++-- test/config/utility.cc | 12 +++++++ test/config/utility.h | 7 ++-- .../udp_proxy/udp_proxy_integration_test.cc | 18 +++++----- .../custom_cluster_integration_test.cc | 2 -- test/integration/eds_integration_test.cc | 1 - test/integration/protocol_integration_test.cc | 34 ++++++------------- 8 files changed, 49 insertions(+), 44 deletions(-) diff --git a/source/common/upstream/health_discovery_service.cc b/source/common/upstream/health_discovery_service.cc index 7e372baeb823f..716339aaaf102 100644 --- a/source/common/upstream/health_discovery_service.cc +++ b/source/common/upstream/health_discovery_service.cc @@ -152,9 +152,11 @@ void HdsDelegate::processMessage( ClusterConnectionBufferLimitBytes); // Add endpoints to cluster + auto* endpoints = cluster_config.mutable_load_assignment()->add_endpoints(); for (const auto& locality_endpoints : cluster_health_check.locality_endpoints()) { for (const auto& endpoint : locality_endpoints.endpoints()) { - cluster_config.add_hidden_envoy_deprecated_hosts()->MergeFrom(endpoint.address()); + endpoints->add_lb_endpoints()->mutable_endpoint()->mutable_address()->MergeFrom( + endpoint.address()); } } @@ -231,9 +233,9 @@ HdsCluster::HdsCluster(Server::Admin& admin, Runtime::Loader& runtime, {admin, runtime_, cluster_, bind_config_, stats_, ssl_context_manager_, added_via_api_, cm, local_info, dispatcher, random, singleton_manager, tls, validation_visitor, api}); - for (const auto& host : cluster.hidden_envoy_deprecated_hosts()) { + for (const auto& host : cluster.load_assignment().endpoints(0).lb_endpoints()) { initial_hosts_->emplace_back(new HostImpl( - info_, "", Network::Address::resolveProtoAddress(host), + info_, "", Network::Address::resolveProtoAddress(host.endpoint().address()), envoy::config::core::v3alpha::Metadata::default_instance(), 1, envoy::config::core::v3alpha::Locality().default_instance(), envoy::config::endpoint::v3alpha::Endpoint::HealthCheckConfig().default_instance(), 0, diff --git a/test/common/upstream/upstream_impl_test.cc b/test/common/upstream/upstream_impl_test.cc index 7619c1192777f..019b35d87dfd0 100644 --- a/test/common/upstream/upstream_impl_test.cc +++ b/test/common/upstream/upstream_impl_test.cc @@ -1566,9 +1566,14 @@ TEST_F(StaticClusterImplTest, UnsupportedLBType) { connect_timeout: 0.25s type: static lb_policy: fakelbtype - hidden_envoy_deprecated_hosts: - - { socket_address: { address: 192.168.1.1, port_value: 22 }} - - { socket_address: { address: 192.168.1.2, port_value: 44 }} + load_assignment: + cluster_name: addressportconfig + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: { address: 192.168.1.1, port_value: 22 } + socket_address: { address: 192.168.1.2, port_value: 44 } )EOF"; EXPECT_THROW_WITH_MESSAGE( diff --git a/test/config/utility.cc b/test/config/utility.cc index 48e845667e262..3bc8eae3a59fa 100644 --- a/test/config/utility.cc +++ b/test/config/utility.cc @@ -344,6 +344,12 @@ ConfigHelper::buildCluster(const std::string& name, int port, const std::string& name, name, ip_version, port)); } +envoy::config::endpoint::v3alpha::Endpoint ConfigHelper::buildEndpoint(const std::string& address) { + envoy::config::endpoint::v3alpha::Endpoint endpoint; + endpoint.mutable_address()->mutable_socket_address()->set_address(address); + return endpoint; +} + ConfigHelper::ConfigHelper(const Network::Address::IpVersion version, Api::Api& api, const std::string& config) { RELEASE_ASSERT(!finalized_, ""); @@ -368,6 +374,9 @@ ConfigHelper::ConfigHelper(const Network::Address::IpVersion version, Api::Api& for (int i = 0; i < static_resources->clusters_size(); ++i) { auto* cluster = static_resources->mutable_clusters(i); + RELEASE_ASSERT( + cluster->hidden_envoy_deprecated_hosts().empty(), + "Hosts should be specified via load_assignment() in the integration test framework."); for (int j = 0; j < cluster->load_assignment().endpoints_size(); ++j) { auto locality_lb = cluster->mutable_load_assignment()->mutable_endpoints(j); for (int k = 0; k < locality_lb->lb_endpoints_size(); ++k) { @@ -430,6 +439,9 @@ void ConfigHelper::finalize(const std::vector& ports) { custom_cluster = true; } else { // Assign ports to statically defined load_assignment hosts. + RELEASE_ASSERT( + cluster->hidden_envoy_deprecated_hosts().empty(), + "Hosts should be specified via load_assignment() in the integration test framework."); for (int j = 0; j < cluster->load_assignment().endpoints_size(); ++j) { auto locality_lb = cluster->mutable_load_assignment()->mutable_endpoints(j); for (int k = 0; k < locality_lb->lb_endpoints_size(); ++k) { diff --git a/test/config/utility.h b/test/config/utility.h index fc9dc1dacbeeb..cd24d352bbd00 100644 --- a/test/config/utility.h +++ b/test/config/utility.h @@ -96,9 +96,12 @@ class ConfigHelper { // api_type should be REST, GRPC, or DELTA_GRPC. static std::string discoveredClustersBootstrap(const std::string& api_type); static std::string adsBootstrap(const std::string& api_type); - // Builds a standard Cluster config fragment, with a single endpoint (at loopback:port). + // Builds a standard Cluster config fragment, with a single endpoint (at address:port). static envoy::config::cluster::v3alpha::Cluster buildCluster(const std::string& name, int port, - const std::string& ip_version); + const std::string& address); + + // Builds a standard Endpoint suitable for population by finalize(). + static envoy::config::endpoint::v3alpha::Endpoint buildEndpoint(const std::string& address); // Run the final config modifiers, and then set the upstream ports based on upstream connections. // This is the last operation run on |bootstrap_| before it is handed to Envoy. diff --git a/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc b/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc index 43d4887cd2593..ac20d48daa2cf 100644 --- a/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc +++ b/test/extensions/filters/udp/udp_proxy/udp_proxy_integration_test.cc @@ -59,16 +59,14 @@ class UdpProxyIntegrationTest : public testing::TestWithParammutable_clusters(0) - ->mutable_load_assignment() - ->mutable_endpoints(0) - ->add_lb_endpoints(); - new_host->MergeFrom(bootstrap.static_resources() - .clusters(0) - .load_assignment() - .endpoints(0) - .lb_endpoints(0)); + bootstrap.mutable_static_resources() + ->mutable_clusters(0) + ->mutable_load_assignment() + ->mutable_endpoints(0) + ->add_lb_endpoints() + ->mutable_endpoint() + ->MergeFrom(ConfigHelper::buildEndpoint( + Network::Test::getLoopbackAddressString(GetParam()))); } }); } diff --git a/test/integration/custom_cluster_integration_test.cc b/test/integration/custom_cluster_integration_test.cc index 821afdde16406..a63e5de9d0870 100644 --- a/test/integration/custom_cluster_integration_test.cc +++ b/test/integration/custom_cluster_integration_test.cc @@ -28,8 +28,6 @@ class CustomClusterIntegrationTest : public testing::TestWithParammutable_clusters(0); - cluster_0->clear_hidden_envoy_deprecated_hosts(); - if (cluster_provided_lb_) { cluster_0->set_lb_policy(envoy::config::cluster::v3alpha::Cluster::CLUSTER_PROVIDED); } diff --git a/test/integration/eds_integration_test.cc b/test/integration/eds_integration_test.cc index 495398fc9b704..68b55ad542222 100644 --- a/test/integration/eds_integration_test.cc +++ b/test/integration/eds_integration_test.cc @@ -113,7 +113,6 @@ class EdsIntegrationTest : public testing::TestWithParamCopyFrom( Protobuf::util::TimeUtil::MillisecondsToDuration(100)); cluster_.set_name("cluster_0"); - cluster_.mutable_hidden_envoy_deprecated_hosts()->Clear(); cluster_.set_type(envoy::config::cluster::v3alpha::Cluster::EDS); auto* eds_cluster_config = cluster_.mutable_eds_cluster_config(); eds_cluster_config->mutable_eds_config()->set_path(eds_helper_.eds_path()); diff --git a/test/integration/protocol_integration_test.cc b/test/integration/protocol_integration_test.cc index 2c344709f4ab9..f7e2de7b5be39 100644 --- a/test/integration/protocol_integration_test.cc +++ b/test/integration/protocol_integration_test.cc @@ -340,18 +340,10 @@ TEST_P(DownstreamProtocolIntegrationTest, RetryPriority) { retry_policy->mutable_retry_priority()->set_name(factory.name()); config_helper_.addVirtualHost(host); // We want to work with a cluster with two hosts. - config_helper_.addConfigModifier([](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) { + config_helper_.addConfigModifier([this](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) { auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); - const std::string host_address = cluster->load_assignment() - .endpoints(0) - .lb_endpoints(0) - .endpoint() - .address() - .socket_address() - .address(); - cluster->clear_load_assignment(); auto* load_assignment = cluster->mutable_load_assignment(); - load_assignment->set_cluster_name(cluster->name()); + load_assignment->clear_endpoints(); for (int i = 0; i < 2; ++i) { auto locality = load_assignment->add_endpoints(); @@ -359,11 +351,8 @@ TEST_P(DownstreamProtocolIntegrationTest, RetryPriority) { locality->mutable_locality()->set_region("region"); locality->mutable_locality()->set_zone("zone"); locality->mutable_locality()->set_sub_zone("sub_zone" + std::to_string(i)); - auto* lb_endpoint = locality->add_lb_endpoints(); - lb_endpoint->mutable_endpoint()->mutable_address()->mutable_socket_address()->set_address( - host_address); - lb_endpoint->mutable_endpoint()->mutable_address()->mutable_socket_address()->set_port_value( - 0); + locality->add_lb_endpoints()->mutable_endpoint()->MergeFrom( + ConfigHelper::buildEndpoint(Network::Test::getLoopbackAddressString(version_))); } }); fake_upstreams_count_ = 2; @@ -419,14 +408,13 @@ TEST_P(DownstreamProtocolIntegrationTest, RetryHostPredicateFilter) { config_helper_.addVirtualHost(host); // We want to work with a cluster with two hosts. - config_helper_.addConfigModifier([](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) { - auto* new_host = bootstrap.mutable_static_resources() - ->mutable_clusters(0) - ->mutable_load_assignment() - ->mutable_endpoints(0) - ->add_lb_endpoints(); - new_host->MergeFrom( - bootstrap.static_resources().clusters(0).load_assignment().endpoints(0).lb_endpoints(0)); + config_helper_.addConfigModifier([this](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) { + bootstrap.mutable_static_resources() + ->mutable_clusters(0) + ->mutable_load_assignment() + ->mutable_endpoints(0) + ->add_lb_endpoints() + ->MergeFrom(ConfigHelper::buildEndpoint(Network::Test::getLoopbackAddressString(version_))); }); fake_upstreams_count_ = 2; initialize(); From 868253fd7e6a06a59507de0b46618a4ec4cb3ef8 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Tue, 14 Jan 2020 18:36:01 -0500 Subject: [PATCH 5/7] Fix. Signed-off-by: Harvey Tuch --- test/integration/protocol_integration_test.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/test/integration/protocol_integration_test.cc b/test/integration/protocol_integration_test.cc index f7e2de7b5be39..cc3f2cc4e6cdf 100644 --- a/test/integration/protocol_integration_test.cc +++ b/test/integration/protocol_integration_test.cc @@ -414,6 +414,7 @@ TEST_P(DownstreamProtocolIntegrationTest, RetryHostPredicateFilter) { ->mutable_load_assignment() ->mutable_endpoints(0) ->add_lb_endpoints() + ->mutable_endpoint() ->MergeFrom(ConfigHelper::buildEndpoint(Network::Test::getLoopbackAddressString(version_))); }); fake_upstreams_count_ = 2; From 73c4d2358d6749aeda9d3e81ebe8a300875e7fb7 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Tue, 14 Jan 2020 20:48:00 -0500 Subject: [PATCH 6/7] Review feedback. Signed-off-by: Harvey Tuch --- test/config/utility.cc | 4 ++-- test/integration/load_stats_integration_test.cc | 1 - test/server/server_fuzz_test.cc | 10 ++++++++++ 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/test/config/utility.cc b/test/config/utility.cc index 3bc8eae3a59fa..004839429cd48 100644 --- a/test/config/utility.cc +++ b/test/config/utility.cc @@ -378,9 +378,9 @@ ConfigHelper::ConfigHelper(const Network::Address::IpVersion version, Api::Api& cluster->hidden_envoy_deprecated_hosts().empty(), "Hosts should be specified via load_assignment() in the integration test framework."); for (int j = 0; j < cluster->load_assignment().endpoints_size(); ++j) { - auto locality_lb = cluster->mutable_load_assignment()->mutable_endpoints(j); + auto* locality_lb = cluster->mutable_load_assignment()->mutable_endpoints(j); for (int k = 0; k < locality_lb->lb_endpoints_size(); ++k) { - auto lb_endpoint = locality_lb->mutable_lb_endpoints(k); + auto* lb_endpoint = locality_lb->mutable_lb_endpoints(k); if (lb_endpoint->endpoint().address().has_socket_address()) { lb_endpoint->mutable_endpoint()->mutable_address()->mutable_socket_address()->set_address( Network::Test::getLoopbackAddressString(version)); diff --git a/test/integration/load_stats_integration_test.cc b/test/integration/load_stats_integration_test.cc index ede1a0b1441ac..95102a6aa0f42 100644 --- a/test/integration/load_stats_integration_test.cc +++ b/test/integration/load_stats_integration_test.cc @@ -127,7 +127,6 @@ class LoadStatsIntegrationTest : public testing::TestWithParamset_sub_zone(sub_zone_); // Switch predefined cluster_0 to EDS filesystem sourcing. auto* cluster_0 = bootstrap.mutable_static_resources()->mutable_clusters(0); - cluster_0->mutable_hidden_envoy_deprecated_hosts()->Clear(); cluster_0->set_type(envoy::config::cluster::v3alpha::Cluster::EDS); auto* eds_cluster_config = cluster_0->mutable_eds_cluster_config(); eds_cluster_config->mutable_eds_config()->set_path(eds_helper_.eds_path()); diff --git a/test/server/server_fuzz_test.cc b/test/server/server_fuzz_test.cc index a923b93078430..33ee6eae5e25c 100644 --- a/test/server/server_fuzz_test.cc +++ b/test/server/server_fuzz_test.cc @@ -58,9 +58,19 @@ makeHermeticPathsAndPorts(Fuzz::PerTestEnvironment& test_env, // Tracked at https://github.com/envoyproxy/envoy/issues/9513. health_check.mutable_http_health_check()->clear_codec_client_type(); } + // We may have both deprecatred hosts() or load_assignment(). for (auto& host : *cluster.mutable_hidden_envoy_deprecated_hosts()) { makePortHermetic(test_env, host); } + for (int j = 0; j < cluster.load_assignment().endpoints_size(); ++j) { + auto* locality_lb = cluster.mutable_load_assignment()->mutable_endpoints(j); + for (int k = 0; k < locality_lb->lb_endpoints_size(); ++k) { + auto* lb_endpoint = locality_lb->mutable_lb_endpoints(k); + if (lb_endpoint->endpoint().address().has_socket_address()) { + makePortHermetic(test_env, *lb_endpoint->mutable_endpoint()->mutable_address()); + } + } + } } return output; } From 207a3f6c3ff6fdd8f11af585be9f58d559e17fe4 Mon Sep 17 00:00:00 2001 From: Harvey Tuch Date: Tue, 14 Jan 2020 21:26:57 -0500 Subject: [PATCH 7/7] Fix spelling. Signed-off-by: Harvey Tuch --- test/server/server_fuzz_test.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/server/server_fuzz_test.cc b/test/server/server_fuzz_test.cc index 33ee6eae5e25c..3082b9b73c5b0 100644 --- a/test/server/server_fuzz_test.cc +++ b/test/server/server_fuzz_test.cc @@ -58,7 +58,7 @@ makeHermeticPathsAndPorts(Fuzz::PerTestEnvironment& test_env, // Tracked at https://github.com/envoyproxy/envoy/issues/9513. health_check.mutable_http_health_check()->clear_codec_client_type(); } - // We may have both deprecatred hosts() or load_assignment(). + // We may have both deprecated hosts() or load_assignment(). for (auto& host : *cluster.mutable_hidden_envoy_deprecated_hosts()) { makePortHermetic(test_env, host); }