Skip to content

Conversation

@klarose
Copy link
Contributor

@klarose klarose commented Jan 21, 2019

Description: This introduces a dedicated class -- ConnPoolMap -- to handle the mapping of "key" to connection pool.

The idea here is that very soon (as part of the work for #4128) we will have an unbounded set of mappings, meaning that we need to manage the life-cycle of these mapped connection pools. Rather than try to do so within ClusterManager, it makes sense to push that responsibility into its own class. This PR starts by refactoring ClusterManager's interaction with the mapping so that it happens entirely through the new class. Future PRs will introduce the life-cycle management.

A few things of note:

  1. The class is templated on the key and connection pool type so that it may be easily reused with the tcp connection pool without any changes to it.
  2. The ClusterManager performed a few operations on the entries in the map -- iterating to add callbacks, draining, etc -- that have been refactored into a single operation on the map. This is probably a good thing, but we should make sure that behaviour wasn't changed here. I don't think any has been.
  3. I had to place some accessor methods in from the of the host map because creating the conn pool map now needs access to the Dispatcher, where previously it did not.
  4. I do not defer deletion of any connection pools when the map is deleted. This is consistent with the existing behaviour. I originally had this behaviour, but it failed some of the existing tests, so I backed it out. It's easy to put back in if desired.
  5. I didn't expect this change to be so large. I can break it into two PRs if desired.

Risk Level: High. Integrates into the core upstream behaviour, but I've striven to ensure that no behaviour changed.
Testing: Unit testing, integration testing.

This class allows clients to map keys to connection pools, returning the
existing pool if it already exists.

Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
@klarose
Copy link
Contributor Author

klarose commented Jan 21, 2019

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: compile_time_options (failed build)

🐱

Caused by: a #5670 (comment) was created by @klarose.

see: more, trace.

@klarose
Copy link
Contributor Author

klarose commented Jan 22, 2019

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: compile_time_options (failed build)
🔨 rebuilding ci/circleci: mac (failed build)

🐱

Caused by: a #5670 (comment) was created by @klarose.

see: more, trace.

We were crashing due to the callback firing mid-iteration and clearing
the pool. Check for that case and handle it.

Signed-off-by: Kyle Larose <kyle@agilicus.com>
@klarose
Copy link
Contributor Author

klarose commented Jan 23, 2019

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: release (failed build)

🐱

Caused by: a #5670 (comment) was created by @klarose.

see: more, trace.

@mattklein123 mattklein123 self-assigned this Jan 24, 2019
@klarose klarose changed the title [upstream] add connpool map upstream: add connpool map Jan 24, 2019
@klarose
Copy link
Contributor Author

klarose commented Jan 29, 2019

@mattklein123 Any chance you'll be able to take a look at this in the next few days?

Thanks!

@mattklein123
Copy link
Member

Yes will do, sorry for the delay.

Copy link
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.

Thanks and sorry for the review delay. At a high level this looks great. Some comments to get started and then I will take another pass.

/wait

Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
 - Fix up comments
 - Add protection against recursion
 - Change optional pointer to a reference

Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
@klarose
Copy link
Contributor Author

klarose commented Feb 1, 2019

@mattklein123 Changes made! Thanks for the feedback.

Copy link
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.

Thanks this looks good. A few small comments.

/wait

 - General cleanup
 - Make recursion checker debug only

Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
@klarose
Copy link
Contributor Author

klarose commented Feb 4, 2019

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: mac (failed build)

🐱

Caused by: a #5670 (comment) was created by @klarose.

see: more, trace.

Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
@mattklein123
Copy link
Member

/retest

@repokitteh-read-only
Copy link

🔨 rebuilding ci/circleci: release (failed build)

🐱

Caused by: a #5670 (comment) was created by @mattklein123.

see: more, trace.

@klarose
Copy link
Contributor Author

klarose commented Feb 5, 2019

@mattklein123 Thanks for kicking off the retest. Looks like everything is passing now. I've addressed all your comments.

Copy link
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.

Looks good, just a few tiny nits then good to go! Thank you!

/wait

Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Kyle Larose <kyle@agilicus.com>
Copy link
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.

Thank you!

@mattklein123 mattklein123 merged commit 6b216b3 into envoyproxy:master Feb 5, 2019
fredlas pushed a commit to fredlas/envoy that referenced this pull request Mar 5, 2019
This class allows clients to map keys to connection pools, returning the
existing pool if it already exists.

Signed-off-by: Kyle Larose <kyle@agilicus.com>
Signed-off-by: Fred Douglas <fredlas@google.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