-
Notifications
You must be signed in to change notification settings - Fork 5.3k
upstream: remove cluster.hosts #6419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -176,34 +176,22 @@ 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<envoy_api_enum_value_Cluster.DiscoveryType.STATIC>`, | ||
| // :ref:`STRICT_DNS<envoy_api_enum_value_Cluster.DiscoveryType.STRICT_DNS>` | ||
| // or :ref:`LOGICAL_DNS<envoy_api_enum_value_Cluster.DiscoveryType.LOGICAL_DNS>`, | ||
| // then hosts is required. | ||
| // | ||
| // .. attention:: | ||
| // | ||
| // **This field is deprecated**. Set the | ||
| // :ref:`load_assignment<envoy_api_field_Cluster.load_assignment>` field instead. | ||
| // | ||
| repeated core.Address hosts = 7 [deprecated = true]; | ||
| reserved 7; // hosts is deprecated by :ref:`load_assignment | ||
| // <envoy_api_field_Cluster.load_assignment>` | ||
| reserved "hosts"; | ||
|
|
||
| // Setting this is required for specifying members of | ||
| // :ref:`STATIC<envoy_api_enum_value_Cluster.DiscoveryType.STATIC>`, | ||
| // :ref:`STRICT_DNS<envoy_api_enum_value_Cluster.DiscoveryType.STRICT_DNS>` | ||
| // or :ref:`LOGICAL_DNS<envoy_api_enum_value_Cluster.DiscoveryType.LOGICAL_DNS>` clusters. | ||
| // This field supersedes :ref:`hosts<envoy_api_field_Cluster.hosts>` field. | ||
| // [#comment:TODO(dio): Deprecate the hosts field and add it to DEPRECATED.md | ||
| // once load_assignment is implemented.] | ||
| // | ||
| // .. attention:: | ||
| // .. note:: | ||
| // | ||
| // Setting this allows non-EDS cluster types to contain embedded EDS equivalent | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. With
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 |
||
| // :ref:`endpoint assignments<envoy_api_msg_ClusterLoadAssignment>`. | ||
| // Setting this overrides :ref:`hosts<envoy_api_field_Cluster.hosts>` values. | ||
| // | ||
| ClusterLoadAssignment load_assignment = 33; | ||
| ClusterLoadAssignment load_assignment = 33 [(gogoproto.nullable) = false]; | ||
|
|
||
| // Optional :ref:`active health checking <arch_overview_health_checking>` | ||
| // configuration for the cluster. If no | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -72,6 +72,7 @@ Version history | |
| routing to certain hosts only when there are insufficient healthy hosts available. | ||
| * upstream: add cluster factory to allow creating and registering :ref:`custom cluster type<arch_overview_service_discovery_types_custom>`. | ||
| * upstream: added a :ref:`circuit breaker <arch_overview_circuit_break_cluster_maximum_connection_pools>` to limit the number of concurrent connection pools in use. | ||
| * upstream: removed cluster.hosts. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
| * tracing: added :ref:`verbose <envoy_api_field_config.filter.network.http_connection_manager.v2.HttpConnectionManager.tracing>` to support logging annotations on spans. | ||
| * upstream: added support for host weighting and :ref:`locality weighting <arch_overview_load_balancing_locality_weighted_lb>` in the :ref:`ring hash load balancer <arch_overview_load_balancing_types_ring_hash>`, and added a :ref:`maximum_ring_size<envoy_api_field_Cluster.RingHashLbConfig.maximum_ring_size>` config parameter to strictly bound the ring size. | ||
| * zookeeper: added a ZooKeeper proxy filter that parses ZooKeeper messages (requests/responses/events). | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -108,26 +108,14 @@ void CdsJson::translateCluster(const Json::Object& json_cluster, | |
| cluster.set_name(name); | ||
|
|
||
| const std::string string_type = json_cluster.getString("type"); | ||
| auto set_dns_hosts = [&json_cluster, &cluster] { | ||
| auto set_dns_hosts = [&json_cluster, &cluster, name] { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why not pass name by ref? |
||
| const auto hosts = json_cluster.getObjectArray("hosts"); | ||
| std::transform(hosts.cbegin(), hosts.cend(), | ||
| Protobuf::RepeatedPtrFieldBackInserter(cluster.mutable_hosts()), | ||
| [](const Json::ObjectSharedPtr& host) { | ||
| envoy::api::v2::core::Address address; | ||
| AddressJson::translateAddress(host->getString("url"), true, false, address); | ||
| return address; | ||
| }); | ||
| translateClusterHosts(name, hosts, true, false, *cluster.mutable_load_assignment()); | ||
| }; | ||
| if (string_type == "static") { | ||
| cluster.set_type(envoy::api::v2::Cluster::STATIC); | ||
| const auto hosts = json_cluster.getObjectArray("hosts"); | ||
| std::transform(hosts.cbegin(), hosts.cend(), | ||
| Protobuf::RepeatedPtrFieldBackInserter(cluster.mutable_hosts()), | ||
| [](const Json::ObjectSharedPtr& host) { | ||
| envoy::api::v2::core::Address address; | ||
| AddressJson::translateAddress(host->getString("url"), true, true, address); | ||
| return address; | ||
| }); | ||
| translateClusterHosts(name, hosts, true, true, *cluster.mutable_load_assignment()); | ||
| } else if (string_type == "strict_dns") { | ||
| cluster.set_type(envoy::api::v2::Cluster::STRICT_DNS); | ||
| set_dns_hosts(); | ||
|
|
@@ -221,5 +209,23 @@ void CdsJson::translateCluster(const Json::Object& json_cluster, | |
| } | ||
| } | ||
|
|
||
| void CdsJson::translateClusterHosts(const std::string& cluster_name, | ||
| const std::vector<Json::ObjectSharedPtr>& json_cluster_hosts, | ||
| bool url, bool resolved, | ||
| envoy::api::v2::ClusterLoadAssignment& load_assignment) { | ||
| // TODO(dio): Early return when json_cluster_hosts is empty. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds like easy enough to do in this PR?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha! |
||
| load_assignment.set_cluster_name(cluster_name); | ||
| auto* locality_lb_endpoints = load_assignment.add_endpoints(); | ||
| // Since this LocalityLbEndpoints is built from hosts list, set the default weight to 1. | ||
| locality_lb_endpoints->mutable_load_balancing_weight()->set_value(1); | ||
| for (const Json::ObjectSharedPtr& json_host : json_cluster_hosts) { | ||
| envoy::api::v2::core::Address address; | ||
| AddressJson::translateAddress(json_host->getString("url"), url, resolved, address); | ||
| auto* lb_endpoint = locality_lb_endpoints->add_lb_endpoints(); | ||
| lb_endpoint->mutable_endpoint()->mutable_address()->MergeFrom(address); | ||
| lb_endpoint->mutable_load_balancing_weight()->set_value(1); | ||
| } | ||
| } | ||
|
|
||
| } // namespace Config | ||
| } // namespace Envoy | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this the way to reserve field names to avoid future YAML/JSON clash? Should we update https://github.com/envoyproxy/envoy/blob/master/api/STYLE.md to enforce this?