cluster_manager: Add support for USE_DOWNSTREAM_PROTOCOL.#2328
cluster_manager: Add support for USE_DOWNSTREAM_PROTOCOL.#2328mattklein123 merged 12 commits intoenvoyproxy:masterfrom
Conversation
Configuration options for different protocols are no longer mutually
exclusive in the v2 API.
Backwards compatibility is maintained by requiring that only one of
HTTP/1 or HTTP/2 options be present when the new cluster option
'protocol_selection' is in it's default value
('EXCLUSIVE_AS_CONFIGURED').
Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
We already test for nullptr values of container pools elsewhere, make sense to do it here as well. Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
source/common/config/cds_json.cc
Outdated
| } | ||
|
|
||
| if (json_cluster.getString("features", "") == "use_downstream_protocol") { | ||
| cluster.set_protocol_selection(envoy::api::v2::Cluster::USE_DOWNSTREAM_PROTOCOL); |
There was a problem hiding this comment.
Can we avoid putting this in v1? We're trying to restrict new features to v2 only to encourage migration, unless there is a direct need for someone to have it in v1.
|
On Jan 9, 2018, at 7:08 AM, htuch ***@***.***> wrote:
@htuch commented on this pull request.
In source/common/config/cds_json.cc <#2328 (comment)>:
> @@ -181,7 +181,12 @@ void CdsJson::translateCluster(const Json::Object& json_cluster,
*cluster.mutable_tls_context());
}
+ if (json_cluster.getString("features", "") == "use_downstream_protocol") {
+ cluster.set_protocol_selection(envoy::api::v2::Cluster::USE_DOWNSTREAM_PROTOCOL);
Can we avoid putting this in v1? We're trying to restrict new features to v2 only to encourage migration, unless there is a direct need for someone to have it in v1.
Sure, will remove.
Jarno
|
Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
Suggested-by: Harvey Tuch <htuch@google.com> Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
Add tests to check that the 'protocol' parameter to httpConnPoolForCluster() is passed correctly with and without the new cluster USE_DOWNSTREAM_PROTOCOL feature. Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
mattklein123
left a comment
There was a problem hiding this comment.
LGTM, just a few nits. Can finalize once data-plane-api PR gets merged. Thank you for the detailed tests.
| */ | ||
| virtual Http::ConnectionPool::Instance* httpConnPoolForCluster(const std::string& cluster, | ||
| ResourcePriority priority, | ||
| enum Http::Protocol protocol, |
There was a problem hiding this comment.
nit: C++ does not require enum. Please remove. Same elsewhere.
| static const uint64_t HTTP2 = 0x1; | ||
| // Use the downstream protocol (HTTP1.1, HTTP2) for upstream connections as well, if available. | ||
| // This is used when creating connection pools. | ||
| static const uint64_t USE_DOWNSTREAM_PROTOCOL = 0x2; |
There was a problem hiding this comment.
note: Needs name update per @wora name change in data-plane-api PR.
source/common/router/router.cc
Outdated
| ENVOY_STREAM_LOG(debug, "getConnPool cluster features: {:x}", *callbacks_, features); | ||
|
|
||
| const Optional<Http::Protocol>& downstream_protocol = callbacks_->requestInfo().protocol(); | ||
| enum Http::Protocol protocol = |
There was a problem hiding this comment.
nit: This multiple tertiary operator is a bit of an eyeful. Can you break apart?
| } | ||
|
|
||
| if (config.protocol_selection() == envoy::api::v2::Cluster::EXCLUSIVE_AS_CONFIGURED) { | ||
| // Make sure multiple protocol configurations are not present |
There was a problem hiding this comment.
nit: period end of sentence
Suggested-by: Matt Klein <mklein@lyft.com> Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
|
mac test failed due to timeout, don't think it is related to this PR: |
e1a4ba2 to
35c3758
Compare
mattklein123
left a comment
There was a problem hiding this comment.
LGTM after few nits. Please merge master also. Thank you!
source/common/router/router.cc
Outdated
| : Http::Protocol::Http11; | ||
| if (features & Upstream::ClusterInfo::Features::USE_DOWNSTREAM_PROTOCOL) { | ||
| const Optional<Http::Protocol>& downstream_protocol = callbacks_->requestInfo().protocol(); | ||
| if (downstream_protocol.valid()) { |
There was a problem hiding this comment.
IIRC protocol must be valid here. I think you can skip the if check.
There was a problem hiding this comment.
Taking your word on this :-)
| HostConstSharedPtr host, | ||
| ResourcePriority priority) override; | ||
| ResourcePriority priority, | ||
| enum Http::Protocol protocol) override; |
There was a problem hiding this comment.
nit: missed enum here, same below.
There was a problem hiding this comment.
Removed extra enums here and elsewhere.
In this context Optional protocol is always valid. Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
Adds an RTDS integration test for Envoy Mobile This test does a simple verification that the RTDS protocol within the xDS family is working correctly. A subsequent PR will improve upon the test coverage. As part of this change, the common parts of running a Envoy Mobile client integration test were refactored out into a new BaseClientIntegrationTest class. Both ClientIntegrationTest and RtdsIntegrationTest inherit from BaseClientIntegrationTest. NB: the parameterized test currently fails when using IPv6. This will be debugged and fixed in a subsequent PR. Signed-off-by: Ali Beyad <abeyad@google.com> Signed-off-by: JP Simard <jp@jpsim.com>
Adds an RTDS integration test for Envoy Mobile This test does a simple verification that the RTDS protocol within the xDS family is working correctly. A subsequent PR will improve upon the test coverage. As part of this change, the common parts of running a Envoy Mobile client integration test were refactored out into a new BaseClientIntegrationTest class. Both ClientIntegrationTest and RtdsIntegrationTest inherit from BaseClientIntegrationTest. NB: the parameterized test currently fails when using IPv6. This will be debugged and fixed in a subsequent PR. Signed-off-by: Ali Beyad <abeyad@google.com> Signed-off-by: JP Simard <jp@jpsim.com>
Currently clusters can not open both HTTP1.1 and HTTP2 upstream
connections at the same time. When the new cluster option
"protocol_selection" is set to "USE_DOWNSTREAM_PROTOCOL", the cluster
must open an HTTP2 upstream connection if the downstream connection is
HTTP2, and an HTTP1.1 upstream connection if the downstream connection
is HTTP1.1. This option is to have no effect if there is no corresponding
downstream connection.
This functionality removes the need to operate multiple clusters and
routing rules for them when the backends accept both HTTP1.1 and HTTP2
connections, and when the choice of the HTTP protocol is significant,
as with gRPC.
Signed-off-by: Jarno Rajahalme jarno@covalent.io
Risk Level: Medium
API Changes: envoyproxy/data-plane-api#399