Skip to content

Commit

Permalink
upstream: Expose the drainConnections method on the connection pool…
Browse files Browse the repository at this point in the history
…. (#22554)

Exposing the drainConnections method on the connection pool, so that Nighthawk can correctly drain the connection pools used by its individual workers.

Fixes #22527.
Works on envoyproxy/nighthawk#873.

/cc @alyssawilk

Risk Level: low, existing functionality isn't affected.
Testing: unit tests.
Docs Changes: n/a.
Release Notes: n/a.
Platform Specific Features: n/a.

Signed-off-by: Jakub Sobon <[email protected]>
  • Loading branch information
mum4k authored and Otto committed Oct 24, 2022
1 parent 84e3f8f commit 59bffd9
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions envoy/upstream/thread_local_cluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ class HttpPoolData {
* See documentation of Envoy::ConnectionPool::Instance.
*/
void addIdleCallback(ConnectionPool::Instance::IdleCb cb) { pool_->addIdleCallback(cb); };
void drainConnections(ConnectionPool::DrainBehavior drain_behavior) {
pool_->drainConnections(drain_behavior);
};

Upstream::HostDescriptionConstSharedPtr host() const { return pool_->host(); }

Expand Down
3 changes: 3 additions & 0 deletions test/common/upstream/cluster_manager_impl_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4248,6 +4248,9 @@ TEST_F(ClusterManagerImplTest, HttpPoolDataForwardsCallsToConnectionPool) {
ConnectionPool::Instance::IdleCb drained_cb = []() {};
EXPECT_CALL(*pool_mock, addIdleCallback(_));
opt_cp.value().addIdleCallback(drained_cb);

EXPECT_CALL(*pool_mock, drainConnections(ConnectionPool::DrainBehavior::DrainAndDelete));
opt_cp.value().drainConnections(ConnectionPool::DrainBehavior::DrainAndDelete);
}

// Test that the read only cross-priority host map in the main thread is correctly synchronized to
Expand Down

0 comments on commit 59bffd9

Please sign in to comment.