Skip to content

http: refactoring http and tcp upstreams#11349

Merged
alyssawilk merged 4 commits into
envoyproxy:masterfrom
alyssawilk:conn_pool_config
Jun 2, 2020
Merged

http: refactoring http and tcp upstreams#11349
alyssawilk merged 4 commits into
envoyproxy:masterfrom
alyssawilk:conn_pool_config

Conversation

@alyssawilk
Copy link
Copy Markdown
Contributor

Moving the choice of http or tcp connection pool from the router to the generic connection pool.

This will allow pluggable connection pools to choose to do HTTP or TCP on their own, as well as getting rid of a bunch of ugly variant logic.

Risk Level: medium (router refactor, ideally no-op)
Testing: existing test pass
Docs Changes: n/a
Release Notes: n/a

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

cc @lambdai

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
@mattklein123 mattklein123 self-assigned this May 28, 2020

// Initializes the connection pool. This must be called before the connection
// pool is valid, and can be used.
virtual bool initialize(Upstream::ClusterManager& cm, const RouteEntry& route_entry,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I am wondering if we can avoid passing the protocol here. But the alternatives are highly coupled with cluster :)

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.

Based on the config proposal that @alyssawilk and I discussed today, I think that ultimately we are going to have to pass the cluster here, as that is where all of the selection logic is going to be stored that will determine which concrete impl to initialize?

I think my larger question is can we avoid an initialize() function entirely? It seems like what we actually will end up needing is a factory which produces a conn pool? I think that is what is going to be needed for the final impl that is pluggable? Alyssa do you want to tackle that now or later? (Personally I think it might be worth it to develop the factory in this PR and use it, even if there is no config that drives it.)

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.

I don't think we can avoid an initialize function or some sort of validity check.
Agree we'll need a factory. My thought was to merge this, and then do the factory and config over in #11327

I think basically that PR will get the config from the cluster, then use that to generate a get a third type of pool, the envoy.default one which creates TCP or HTTP based on "is this a connect request"

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.

actually I take that back - we can avoid the initialize function if we allow the factory creation function to return nullptr, if we prefer that mode

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.

Yeah this is what I had assumed we would do. Do you want to do that in this PR or in a follow up?

Comment thread source/common/router/router.h Outdated
HttpOrTcpPool createConnPool(Upstream::HostDescriptionConstSharedPtr& host);
UpstreamRequestPtr createUpstreamRequest(Filter::HttpOrTcpPool conn_pool);
std::unique_ptr<GenericConnPool> createConnPool();
UpstreamRequestPtr createUpstreamRequest(std::unique_ptr<GenericConnPool>&& conn_pool);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Mark: I don't see the definition in PR... github issue?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I didn't find the impl anywhere but envoy is built successfully... Please educate me
My initial intention is to argue if we need the rvalue reference "&&" in parameter

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

@lambdai lambdai left a comment

Choose a reason for hiding this comment

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

Awesome!

Comment thread source/common/router/upstream_request.h Outdated
private:
// Points to the actual connection pool to create streams from.
Http::ConnectionPool::Instance& conn_pool_;
Http::ConnectionPool::Instance* conn_pool_;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

nit: now that it's no longer reference we can assign the default value '{}'

Comment thread source/common/router/upstream_request.h Outdated
class TcpConnPool : public GenericConnPool, public Tcp::ConnectionPool::Callbacks {
public:
TcpConnPool(Tcp::ConnectionPool::Instance* conn_pool) : conn_pool_(conn_pool) {}
TcpConnPool() = default;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ditto

Comment thread source/common/router/upstream_request.h Outdated
class HttpConnPool : public GenericConnPool, public Http::ConnectionPool::Callbacks {
public:
HttpConnPool(Http::ConnectionPool::Instance& conn_pool) : conn_pool_(conn_pool) {}
HttpConnPool() = default;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is the required?

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 modulo @lambdai comments and one larger question about structure. Thank you!

/wait


// Initializes the connection pool. This must be called before the connection
// pool is valid, and can be used.
virtual bool initialize(Upstream::ClusterManager& cm, const RouteEntry& route_entry,
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.

Based on the config proposal that @alyssawilk and I discussed today, I think that ultimately we are going to have to pass the cluster here, as that is where all of the selection logic is going to be stored that will determine which concrete impl to initialize?

I think my larger question is can we avoid an initialize() function entirely? It seems like what we actually will end up needing is a factory which produces a conn pool? I think that is what is going to be needed for the final impl that is pluggable? Alyssa do you want to tackle that now or later? (Personally I think it might be worth it to develop the factory in this PR and use it, even if there is no config that drives it.)

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

follow up if you're OK with the churn - I've got the next in line mostly ready to go and would prefer to start the config discussion earlier than later.

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.

OK sounds good to do a follow up.

@alyssawilk alyssawilk merged commit b9aff55 into envoyproxy:master Jun 2, 2020
aunu53 pushed a commit to aunu53/envoy that referenced this pull request Jun 4, 2020
Moving the choice of http or tcp connection pool from the router to the generic connection pool.

This will allow pluggable connection pools to choose to do HTTP or TCP on their own, as well as getting rid of a bunch of ugly variant logic.

Risk Level: medium (router refactor, ideally no-op)
Testing: existing test pass
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: Auni Ahsan <auni@google.com>
yashwant121 pushed a commit to yashwant121/envoy that referenced this pull request Jul 24, 2020
Moving the choice of http or tcp connection pool from the router to the generic connection pool.

This will allow pluggable connection pools to choose to do HTTP or TCP on their own, as well as getting rid of a bunch of ugly variant logic.

Risk Level: medium (router refactor, ideally no-op)
Testing: existing test pass
Docs Changes: n/a
Release Notes: n/a

Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
Signed-off-by: yashwant121 <yadavyashwant36@gmail.com>
@alyssawilk alyssawilk deleted the conn_pool_config branch September 30, 2020 15:45
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