Skip to content

cluster_manager: Add support for USE_DOWNSTREAM_PROTOCOL.#2328

Merged
mattklein123 merged 12 commits intoenvoyproxy:masterfrom
jrajahalme:auto_http2
Jan 11, 2018
Merged

cluster_manager: Add support for USE_DOWNSTREAM_PROTOCOL.#2328
mattklein123 merged 12 commits intoenvoyproxy:masterfrom
jrajahalme:auto_http2

Conversation

@jrajahalme
Copy link
Copy Markdown
Contributor

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

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>
}

if (json_cluster.getString("features", "") == "use_downstream_protocol") {
cluster.set_protocol_selection(envoy::api::v2::Cluster::USE_DOWNSTREAM_PROTOCOL);
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@jrajahalme
Copy link
Copy Markdown
Contributor Author

jrajahalme commented Jan 9, 2018 via email

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>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: C++ does not require enum. Please remove. Same elsewhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

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;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note: Needs name update per @wora name change in data-plane-api PR.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

ENVOY_STREAM_LOG(debug, "getConnPool cluster features: {:x}", *callbacks_, features);

const Optional<Http::Protocol>& downstream_protocol = callbacks_->requestInfo().protocol();
enum Http::Protocol protocol =
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This multiple tertiary operator is a bit of an eyeful. Can you break apart?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Refactored.

}

if (config.protocol_selection() == envoy::api::v2::Cluster::EXCLUSIVE_AS_CONFIGURED) {
// Make sure multiple protocol configurations are not present
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: period end of sentence

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Suggested-by: Matt Klein <mklein@lyft.com>
Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
Signed-off-by: Jarno Rajahalme <jarno@covalent.io>
@jrajahalme
Copy link
Copy Markdown
Contributor Author

mac test failed due to timeout, don't think it is related to this PR:

//test/integration:http2_integration_test                               TIMEOUT in 316.1s
  /private/var/tmp/_bazel_distiller/bedaa68a8664d1b29e96b826d058247f/execroot/envoy/bazel-out/darwin-fastbuild/testlogs/test/integration/http2_integration_test/test.log

Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM after few nits. Please merge master also. Thank you!

: Http::Protocol::Http11;
if (features & Upstream::ClusterInfo::Features::USE_DOWNSTREAM_PROTOCOL) {
const Optional<Http::Protocol>& downstream_protocol = callbacks_->requestInfo().protocol();
if (downstream_protocol.valid()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC protocol must be valid here. I think you can skip the if check.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Taking your word on this :-)

HostConstSharedPtr host,
ResourcePriority priority) override;
ResourcePriority priority,
enum Http::Protocol protocol) override;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: missed enum here, same below.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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>
Copy link
Copy Markdown
Member

@mattklein123 mattklein123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, thanks!

@mattklein123 mattklein123 merged commit 172fb8a into envoyproxy:master Jan 11, 2018
@jrajahalme
Copy link
Copy Markdown
Contributor Author

jrajahalme commented Jan 11, 2018 via email

@jrajahalme jrajahalme deleted the auto_http2 branch January 11, 2018 20:09
Shikugawa pushed a commit to Shikugawa/envoy that referenced this pull request Mar 28, 2020
jpsim pushed a commit that referenced this pull request Nov 28, 2022
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>
jpsim pushed a commit that referenced this pull request Nov 29, 2022
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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants