Skip to content

conn_pool: Remove startDrain() and replace it with an argument to drainConnections - #17960

Merged
mattklein123 merged 10 commits into
envoyproxy:mainfrom
RyanTheOptimist:StartDrain
Sep 7, 2021
Merged

mattklein123 merged 10 commits into
envoyproxy:mainfrom
RyanTheOptimist:StartDrain

Conversation

@RyanTheOptimist

Copy link
Copy Markdown
Contributor

conn_pool: Remove startDrain() and replace it with an argument to drainConnections

Add a new DrainBehavior enum argument to drainConnections() and use that to replace startDrain().

Risk Level: Low
Testing: Unit tests
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features: N/A

Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
Signed-off-by: Ryan Hamilton <[email protected]>
@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

/assign @mattklein123

@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

/assign @ggreenway

@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

Hopefully this is what we discussed! :)

Signed-off-by: Ryan Hamilton <[email protected]>

@ggreenway ggreenway left a comment

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.

Interface changes look good.

/wait

void ConnPoolImplBase::drainConnectionsImpl() {
void ConnPoolImplBase::drainConnectionsImpl(DrainBehavior drain_behavior) {
if (drain_behavior == Envoy::ConnectionPool::DrainBehavior::DrainAndDelete) {
checkForIdleAndCloseIdleConnsIfDraining();

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 function behaves differently depending on the value of is_draining_. You've re-ordered these operations, which changes the behavior. I think the behavior was correct with is_draining_ = true before the function call.

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.

Oh shoot! Thanks. I think I screwed that up during a cleanup. Fixed.

Comment thread envoy/common/conn_pool.h
* Controls the behavior when draining a connection pool.
*/
enum class DrainBehavior {
// Starts draining a pool, by gracefully completing all requests and gracefully closing all

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.

Please add that it is invalid to create new requests/streams/connections on this pool after this call.

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.

Good idea. Done.

Comment thread envoy/common/conn_pool.h Outdated
enum class DrainBehavior {
// Starts draining a pool, by gracefully completing all requests and gracefully closing all
// connections, in preparation for deletion.
// can be immediately drained.

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 this a proper 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.

Oh whoop. That should just be removed. Done.

Signed-off-by: Ryan Hamilton <[email protected]>

@RyanTheOptimist RyanTheOptimist left a comment

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.

Thanks!

void ConnPoolImplBase::drainConnectionsImpl() {
void ConnPoolImplBase::drainConnectionsImpl(DrainBehavior drain_behavior) {
if (drain_behavior == Envoy::ConnectionPool::DrainBehavior::DrainAndDelete) {
checkForIdleAndCloseIdleConnsIfDraining();

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.

Oh shoot! Thanks. I think I screwed that up during a cleanup. Fixed.

Comment thread envoy/common/conn_pool.h
* Controls the behavior when draining a connection pool.
*/
enum class DrainBehavior {
// Starts draining a pool, by gracefully completing all requests and gracefully closing all

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.

Good idea. Done.

Comment thread envoy/common/conn_pool.h Outdated
enum class DrainBehavior {
// Starts draining a pool, by gracefully completing all requests and gracefully closing all
// connections, in preparation for deletion.
// can be immediately drained.

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.

Oh whoop. That should just be removed. Done.

ggreenway
ggreenway previously approved these changes Sep 2, 2021

@ggreenway ggreenway left a comment

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.

LGTM. Thanks!

@mattklein123 mattklein123 left a comment

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.

Awesome, thanks. One question.

/wait-any

void ConnPoolImplBase::drainConnectionsImpl() {
void ConnPoolImplBase::drainConnectionsImpl(DrainBehavior drain_behavior) {
if (drain_behavior == Envoy::ConnectionPool::DrainBehavior::DrainAndDelete) {
is_draining_ = true;

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 thought we wanted to add more asserts that no new streams are created if is_draining_ is true? Am I missing that?

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.

Ah yes, good point! I've added an ASSERT in ConnPoolImplBase::newStreamImpl. It did make me wonder if we should rename is_draining_ to is_draining_for_deletion_ to match the name of the enum (and sine it's not set on all drain behaviors, just one of them).

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.

Sure renaming SGTM (or just store the enum itself somehow)

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.

Renamed. I notice this matches the description in the .h file nicely now:

  // Whether the connection pool is currently in the process of closing                                                                                                                                                     
  // all connections so that it can be gracefully deleted.                                                                                                                                                                  

It's like we planned it or something :)

Signed-off-by: Ryan Hamilton <[email protected]>
@mattklein123

Copy link
Copy Markdown
Member

Thanks. Check format?

/wait

Signed-off-by: Ryan Hamilton <[email protected]>
@RyanTheOptimist

Copy link
Copy Markdown
Contributor Author

Thanks. Check format?

facepalm Done.

mattklein123
mattklein123 previously approved these changes Sep 3, 2021

@mattklein123 mattklein123 left a comment

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.

Thanks!

@mattklein123

Copy link
Copy Markdown
Member

Sorry looks like tidy is failing also. Might be pre-existing. Do you mind trying to fix?

/wait

Signed-off-by: Ryan Hamilton <[email protected]>
@mattklein123
mattklein123 merged commit 84efbaf into envoyproxy:main Sep 7, 2021
tyxia pushed a commit to tyxia/envoy that referenced this pull request Sep 21, 2021
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