Skip to content

tcp: add an (unused-by-default) connection pool based on a shared-with-HTTP class.#11756

Merged
alyssawilk merged 9 commits intoenvoyproxy:masterfrom
alyssawilk:conn_pool_rebase
Jul 6, 2020
Merged

tcp: add an (unused-by-default) connection pool based on a shared-with-HTTP class.#11756
alyssawilk merged 9 commits intoenvoyproxy:masterfrom
alyssawilk:conn_pool_rebase

Conversation

@alyssawilk
Copy link
Copy Markdown
Contributor

Risk Level: low (defaulted off until release)
Testing: parameterized existing unit, integration tests.
Docs Changes: n/a
Release Notes: n/a (will add with flip
Runtime guard: envoy.reloadable_features.new_tcp_connection_pool (default off)
Fixes #11528 (modulo TODO and cleanup)

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Copy Markdown
Contributor Author

looks like something didn't merge cleanly with the callback change - passes locally but flakes on other builds :-/

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Comment thread source/common/tcp/conn_pool.cc
Comment thread source/common/tcp/conn_pool.h Outdated
TcpPendingRequest(Envoy::ConnectionPool::ConnPoolImplBase& parent,
Tcp::ConnectionPool::Callbacks& callbacks)
: Envoy::ConnectionPool::PendingRequest(parent), callbacks_(callbacks) {}
void* context() override { return static_cast<void*>(&callbacks_); }
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.

I'm not a fan of the void*, but I assume that's part of the interface?

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.

Yeah, potential workaround in #11796


void ActiveTcpClient::onEvent(Network::ConnectionEvent event) {
Envoy::ConnectionPool::ActiveClient::onEvent(event);
if (callbacks_ && event != Network::ConnectionEvent::Connected) {
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.

This block is confusing to read. Why only not-connected events? And why clear callbacks_ after? Is it because the only other event types are Close events? Please add a comment here on what this is doing (and why it can't be handled in the base class).

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.

yeah, so the TCP proxy session is "weird" and synthesizes a connection event on assignment (legacy - it used to get a connected event and do "on begin" logic then, but then we supported reusing connections and blocked the connect event and synthesized another.
It should be a fairly simple clean up - I left a comment and a TODO so this could be a no-op PR, but given it's fairly self contained LMK if you want me to just do it in this PR.

Comment thread source/common/tcp/conn_pool.h
Comment thread source/common/tcp/conn_pool.h Outdated
Comment thread source/common/tcp/conn_pool.h Outdated
Comment thread source/common/tcp/conn_pool.h Outdated
}

void onPoolReady(Envoy::ConnectionPool::ActiveClient& client, void* context) override {
ActiveTcpClient* tcp_client = reinterpret_cast<ActiveTcpClient*>(&client);
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.

static_cast

Comment thread source/common/tcp/conn_pool.h Outdated
auto* callbacks = reinterpret_cast<Tcp::ConnectionPool::Callbacks*>(context);
std::unique_ptr<Envoy::Tcp::ConnectionPool::ConnectionData> connection_data =
Envoy::Tcp::ConnectionPool::ConnectionDataPtr{
new ActiveTcpClient::TcpConnectionData(*tcp_client, *tcp_client->connection_)};
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.

make_unique

Comment thread source/common/tcp/conn_pool.h Outdated

protected:
Event::SchedulableCallbackPtr upstream_ready_cb_;
bool upstream_ready_enabled_ = false;
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.

I think we've been using {false} more commonly, instead of = false for in-class init.

new Tcp::OriginalConnPoolImpl(dispatcher, host, priority, options, transport_socket_options)};
if (Runtime::runtimeFeatureEnabled("envoy.reloadable_features.new_tcp_connection_pool")) {
return Tcp::ConnectionPool::InstancePtr{
new Tcp::ConnPoolImpl(dispatcher, host, priority, options, transport_socket_options)};
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.

make_unique

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
ggreenway
ggreenway previously approved these changes Jun 30, 2020
Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

LGTM. It's up to you if you want to merge this before or after the void*->AttachContext change.

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Copy Markdown
Contributor Author

ok, one last pass now without the void* pointers :-)

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk
Copy link
Copy Markdown
Contributor Author

@ggreenway can I get an LGTM on the merge when you get a chance?

ggreenway
ggreenway previously approved these changes Jul 6, 2020
Copy link
Copy Markdown
Member

@ggreenway ggreenway left a comment

Choose a reason for hiding this comment

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

LGTM, but there's a merge conflict

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@alyssawilk alyssawilk merged commit 3aa6259 into envoyproxy:master Jul 6, 2020
scheler pushed a commit to scheler/envoy that referenced this pull request Aug 4, 2020
…h-HTTP class. (envoyproxy#11756)

Risk Level: low (defaulted off until release)
Testing: parameterized existing unit, integration tests.
Docs Changes: n/a
Release Notes: n/a (will add with flip
Runtime guard: envoy.reloadable_features.new_tcp_connection_pool (default off)
Fixes envoyproxy#11528 (modulo TODO and cleanup)

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: scheler <santosh.cheler@appdynamics.com>
@alyssawilk alyssawilk deleted the conn_pool_rebase branch October 26, 2020 21:16
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.

Share code between TCP and HTTP connection pools

2 participants