Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions source/common/conn_pool/conn_pool_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -577,10 +577,6 @@ ActiveClient::ActiveClient(ConnPoolImplBase& parent, uint32_t lifetime_stream_li

ActiveClient::~ActiveClient() { releaseResourcesBase(); }

void ActiveClient::onEvent(Network::ConnectionEvent event) {
parent_.onConnectionEvent(*this, "", event);
}

void ActiveClient::releaseResourcesBase() {
if (!resources_released_) {
resources_released_ = true;
Expand Down
1 change: 0 additions & 1 deletion source/common/conn_pool/conn_pool_base.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class ActiveClient : public LinkedObject<ActiveClient>,
void releaseResourcesBase();

// Network::ConnectionCallbacks
void onEvent(Network::ConnectionEvent event) override;
void onAboveWriteBufferHighWatermark() override {}
void onBelowWriteBufferLowWatermark() override {}

Expand Down
2 changes: 1 addition & 1 deletion source/common/tcp/conn_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ void ActiveTcpClient::onEvent(Network::ConnectionEvent event) {
if (event == Network::ConnectionEvent::Connected) {
connection_->readDisable(true);
}
Envoy::ConnectionPool::ActiveClient::onEvent(event);
parent_.onConnectionEvent(*this, connection_->transportFailureReason(), event);
if (callbacks_) {
// Do not pass the Connected event to any session which registered during onEvent above.
// Consumers of connection pool connections assume they are receiving already connected
Expand Down
3 changes: 2 additions & 1 deletion source/common/tcp/original_conn_pool.cc
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,8 @@ void OriginalConnPoolImpl::onConnectionEvent(ActiveConn& conn, Network::Connecti
PendingRequestPtr request =
pending_requests_to_purge.front()->removeFromList(pending_requests_to_purge);
host_->cluster().stats().upstream_rq_pending_failure_eject_.inc();
request->callbacks_.onPoolFailure(reason, "", conn.real_host_description_);
request->callbacks_.onPoolFailure(reason, conn.conn_->transportFailureReason(),
conn.real_host_description_);
}
}

Expand Down
3 changes: 3 additions & 0 deletions test/common/conn_pool/conn_pool_base_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ class TestActiveClient : public ActiveClient {
bool closingWithIncompleteStream() const override { return false; }
uint32_t numActiveStreams() const override { return active_streams_; }
absl::optional<Http::Protocol> protocol() const override { return absl::nullopt; }
void onEvent(Network::ConnectionEvent event) override {
parent_.onConnectionEvent(*this, "", event);
}

uint32_t active_streams_{};
};
Expand Down
8 changes: 7 additions & 1 deletion test/common/tcp/conn_pool_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,11 @@ struct ConnPoolCallbacks : public Tcp::ConnectionPool::Callbacks {
pool_ready_.ready();
}

void onPoolFailure(ConnectionPool::PoolFailureReason reason, absl::string_view,
void onPoolFailure(ConnectionPool::PoolFailureReason reason, absl::string_view failure_reason,
Upstream::HostDescriptionConstSharedPtr host) override {
reason_ = reason;
host_ = host;
failure_reason_string_ = std::string(failure_reason);
pool_failure_.ready();
}

Expand All @@ -73,6 +74,7 @@ struct ConnPoolCallbacks : public Tcp::ConnectionPool::Callbacks {
ReadyWatcher pool_ready_;
ConnectionPool::ConnectionDataPtr conn_data_{};
absl::optional<ConnectionPool::PoolFailureReason> reason_;
std::string failure_reason_string_;
Upstream::HostDescriptionConstSharedPtr host_;
Ssl::ConnectionInfoConstSharedPtr ssl_;
};
Expand Down Expand Up @@ -321,6 +323,7 @@ class TcpConnPoolImplDestructorTest : public Event::TestUsingSimulatedTime,

void prepareConn() {
connection_ = new StrictMock<Network::MockClientConnection>();
EXPECT_CALL(*connection_, transportFailureReason()).Times(AtLeast(0));
EXPECT_CALL(*connection_, setBufferLimits(0));
EXPECT_CALL(*connection_, detectEarlyCloseWhenReadDisabled(false));
EXPECT_CALL(*connection_, addConnectionCallbacks(_));
Expand Down Expand Up @@ -650,10 +653,13 @@ TEST_P(TcpConnPoolImplTest, RemoteConnectFailure) {
EXPECT_CALL(*conn_pool_->test_conns_[0].connect_timer_, disableTimer());

EXPECT_CALL(*conn_pool_, onConnDestroyedForTest());
EXPECT_CALL(*conn_pool_->test_conns_[0].connection_, transportFailureReason())
.WillOnce(Return("foo"));
conn_pool_->test_conns_[0].connection_->raiseEvent(Network::ConnectionEvent::RemoteClose);
dispatcher_.clearDeferredDeleteList();

EXPECT_EQ(ConnectionPool::PoolFailureReason::RemoteConnectionFailure, callbacks.reason_);
EXPECT_EQ("foo", callbacks.failure_reason_string_);

EXPECT_EQ(1U, cluster_->stats_.upstream_cx_connect_fail_.value());
EXPECT_EQ(1U, cluster_->stats_.upstream_rq_pending_failure_eject_.value());
Expand Down