From ab965195f6e238b5b66312497b19e9503f22cfb2 Mon Sep 17 00:00:00 2001 From: htuch Date: Wed, 15 Jan 2020 12:15:23 -0500 Subject: [PATCH] api: deprecate hosts in Cluster. (#9663) 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 +---- examples/grpc-bridge/server/envoy-proxy.yaml | 13 ++- .../envoy/api/v2/cluster.proto | 2 +- .../config/cluster/v3alpha/cluster.proto | 2 +- source/common/config/version_converter.cc | 2 +- .../upstream/health_discovery_service.cc | 8 +- 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/common/config/version_converter_test.cc | 4 +- test/common/upstream/upstream_impl_test.cc | 11 ++- .../google_com_proxy_port_0.v2.yaml | 7 +- test/config/integration/server.yaml | 65 +++++++++----- .../integration/server_unix_listener.yaml | 13 ++- test/config/utility.cc | 84 +++++++++++-------- test/config/utility.h | 7 +- .../aggregate/cluster_integration_test.cc | 13 ++- .../redis/redis_cluster_integration_test.cc | 48 +++++++---- .../udp_proxy/udp_proxy_integration_test.cc | 11 ++- test/integration/ads_integration.h | 13 ++- .../custom_cluster_integration_test.cc | 2 - test/integration/eds_integration_test.cc | 1 - 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 +- .../load_stats_integration_test.cc | 1 - test/integration/protocol_integration_test.cc | 33 ++++---- .../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 +- test/server/server_fuzz_test.cc | 12 ++- 39 files changed, 333 insertions(+), 197 deletions(-) diff --git a/api/envoy/api/v2/cluster.proto b/api/envoy/api/v2/cluster.proto index a92dd0b0b3e8..154c861fd151 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 9e3ede65efe9..83e8c017d401 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/examples/grpc-bridge/server/envoy-proxy.yaml b/examples/grpc-bridge/server/envoy-proxy.yaml index fea386492836..de25aa91f822 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/generated_api_shadow/envoy/api/v2/cluster.proto b/generated_api_shadow/envoy/api/v2/cluster.proto index a92dd0b0b3e8..154c861fd151 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 1a502f636c8d..6ab4df3c82fe 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/config/version_converter.cc b/source/common/config/version_converter.cc index 787ab1084bf6..af7caa972e17 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/source/common/upstream/health_discovery_service.cc b/source/common/upstream/health_discovery_service.cc index 6a6e7c4abf41..716339aaaf10 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_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.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/source/common/upstream/logical_dns_cluster.cc b/source/common/upstream/logical_dns_cluster.cc index fb4c5a61a1b0..ff7edf982b56 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 9440aa9e9e94..a2d7a1461b5b 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 1f235cdc0bb4..a1d537585bb6 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 45d6b2ffa15b..c1992a95632f 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 be8704841f81..3faff0b8fdad 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/common/config/version_converter_test.cc b/test/common/config/version_converter_test.cc index 35de12e06a08..c6d42053a37e 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 b82920e2a676..019b35d87dfd 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 - 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/integration/google_com_proxy_port_0.v2.yaml b/test/config/integration/google_com_proxy_port_0.v2.yaml index 67f4e54d2922..f6f33aa33a91 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 3813fa137bdf..15456cc95b45 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 72c4e98597f6..56ce466da30c 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 c866e12afb8a..004839429cd4 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: @@ -324,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_, ""); @@ -348,18 +374,13 @@ 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(); - host_socket_addr->set_address(Network::Test::getLoopbackAddressString(version)); - } - } - } + 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); + 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)); @@ -417,15 +438,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(); - RELEASE_ASSERT(ports.size() > port_idx, ""); - host_socket_addr->set_port_value(ports[port_idx++]); - } - } - // 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 fc9dc1dacbee..cd24d352bbd0 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/clusters/aggregate/cluster_integration_test.cc b/test/extensions/clusters/aggregate/cluster_integration_test.cc index 49377004908d..5d416d4423ff 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 46e3b96e75dd..fd31482e554f 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,15 +158,19 @@ 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(); - 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 1fb006d2acc4..ac20d48daa2c 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,14 @@ class UdpProxyIntegrationTest : public testing::TestWithParammutable_clusters(0)->add_hosts(); - new_host->MergeFrom(bootstrap.static_resources().clusters(0).hosts(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/ads_integration.h b/test/integration/ads_integration.h index cf5e76ef10a8..f7cc9d4c29ab 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/custom_cluster_integration_test.cc b/test/integration/custom_cluster_integration_test.cc index d092870e5e41..a63e5de9d087 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_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 120b110022c8..68b55ad54222 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_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 61e8b7ba99c7..db8bd671841d 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->clear_load_assignment(); }); HttpIntegrationTest::initialize(); diff --git a/test/integration/header_integration_test.cc b/test/integration/header_integration_test.cc index 155ddc6c7de4..b2a3e4e3c046 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 c6a9fff5a80e..e02d34eeedc2 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_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_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 8c5d9e6af6c7..4874e1dba834 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_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/load_stats_integration_test.cc b/test/integration/load_stats_integration_test.cc index 94e107d711e4..95102a6aa0f4 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_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 1109fc28e3f9..cc3f2cc4e6cd 100644 --- a/test/integration/protocol_integration_test.cc +++ b/test/integration/protocol_integration_test.cc @@ -339,13 +339,11 @@ 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. - 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(); - load_assignment->set_cluster_name(cluster->name()); - const auto& host_address = cluster->hosts(0).socket_address().address(); + // We want to work with a cluster with two hosts. + config_helper_.addConfigModifier([this](envoy::config::bootstrap::v3alpha::Bootstrap& bootstrap) { + auto* cluster = bootstrap.mutable_static_resources()->mutable_clusters(0); + auto* load_assignment = cluster->mutable_load_assignment(); + load_assignment->clear_endpoints(); for (int i = 0; i < 2; ++i) { auto locality = load_assignment->add_endpoints(); @@ -353,16 +351,10 @@ 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_))); } - - cluster->clear_hosts(); }); - fake_upstreams_count_ = 2; initialize(); codec_client_ = makeHttpConnection(lookupPort("http")); @@ -416,9 +408,14 @@ 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)->add_hosts(); - new_host->MergeFrom(bootstrap.static_resources().clusters(0).hosts(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() + ->mutable_endpoint() + ->MergeFrom(ConfigHelper::buildEndpoint(Network::Test::getLoopbackAddressString(version_))); }); fake_upstreams_count_ = 2; initialize(); diff --git a/test/integration/proxy_proto_integration_test.cc b/test/integration/proxy_proto_integration_test.cc index 45fe46936ba6..84cb1cd01f9e 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->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_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 4921d821c76c..30000e4d6686 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 28a86a8fc43b..b60ac7e34f9f 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_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 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 @@ -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, 1655); } } // namespace diff --git a/test/integration/transport_socket_match_integration_test.cc b/test/integration/transport_socket_match_integration_test.cc index db087bc076a2..9b80a75e5301 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_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 82432b29c74e..b911e5a704ba 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->hosts_size(); ++j) { - cluster->mutable_hosts(j)->clear_socket_address(); - cluster->mutable_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 e8cdeb421489..091ac8790dc2 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 5524b3e9ec51..f9baefd1018c 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" diff --git a/test/server/server_fuzz_test.cc b/test/server/server_fuzz_test.cc index cb65c8872b35..f5b6c699bbda 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(); } - for (auto& host : *cluster.mutable_hosts()) { + // We may have both deprecated 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; }