Skip to content

Commit 62ca8bd

Browse files
authored
http: forwarding transport failure details for CONNECT and ALPN connections (#16975)
Previously, L7 connections forwarded over TCP didn't get connection failure details (auto_http before codec assignment, CONNECT requests during the entire lifetime) but now they should. Risk Level: low Testing: unit test. Docs Changes: n/a Release Notes: n/a Fixes #/16881 Signed-off-by: Alyssa Wilk <alyssar@chromium.org>
1 parent ed81f0c commit 62ca8bd

File tree

18 files changed

+25
-15
lines changed

18 files changed

+25
-15
lines changed

envoy/tcp/conn_pool.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,11 @@ class Callbacks {
103103
/**
104104
* Called when a pool error occurred and no connection could be acquired for making the request.
105105
* @param reason supplies the failure reason.
106+
* @param transport_failure_reason supplies the details of the transport failure reason.
106107
* @param host supplies the description of the host that caused the failure. This may be nullptr
107108
* if no host was involved in the failure (for example overflow).
108109
*/
109-
virtual void onPoolFailure(PoolFailureReason reason,
110+
virtual void onPoolFailure(PoolFailureReason reason, absl::string_view transport_failure_reason,
110111
Upstream::HostDescriptionConstSharedPtr host) PURE;
111112

112113
/**

source/common/tcp/conn_pool.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,10 @@ class ConnPoolImpl : public Envoy::ConnectionPool::ConnPoolImplBase,
204204
}
205205

206206
void onPoolFailure(const Upstream::HostDescriptionConstSharedPtr& host_description,
207-
absl::string_view, ConnectionPool::PoolFailureReason reason,
207+
absl::string_view failure_reason, ConnectionPool::PoolFailureReason reason,
208208
Envoy::ConnectionPool::AttachContext& context) override {
209209
auto* callbacks = typedContext<TcpAttachContext>(context).callbacks_;
210-
callbacks->onPoolFailure(reason, host_description);
210+
callbacks->onPoolFailure(reason, failure_reason, host_description);
211211
}
212212

213213
// These two functions exist for testing parity between old and new Tcp Connection Pools.

source/common/tcp/original_conn_pool.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ OriginalConnPoolImpl::newConnection(ConnectionPool::Callbacks& callbacks) {
128128
return pending_requests_.front().get();
129129
} else {
130130
ENVOY_LOG(debug, "max pending requests overflow");
131-
callbacks.onPoolFailure(ConnectionPool::PoolFailureReason::Overflow, nullptr);
131+
callbacks.onPoolFailure(ConnectionPool::PoolFailureReason::Overflow, "", nullptr);
132132
host_->cluster().stats().upstream_rq_pending_overflow_.inc();
133133
return nullptr;
134134
}
@@ -184,7 +184,7 @@ void OriginalConnPoolImpl::onConnectionEvent(ActiveConn& conn, Network::Connecti
184184
PendingRequestPtr request =
185185
pending_requests_to_purge.front()->removeFromList(pending_requests_to_purge);
186186
host_->cluster().stats().upstream_rq_pending_failure_eject_.inc();
187-
request->callbacks_.onPoolFailure(reason, conn.real_host_description_);
187+
request->callbacks_.onPoolFailure(reason, "", conn.real_host_description_);
188188
}
189189
}
190190

source/common/tcp_proxy/upstream.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ void TcpConnPool::newStream(GenericConnectionPoolCallbacks& callbacks) {
172172
}
173173
}
174174

175-
void TcpConnPool::onPoolFailure(ConnectionPool::PoolFailureReason reason,
175+
void TcpConnPool::onPoolFailure(ConnectionPool::PoolFailureReason reason, absl::string_view,
176176
Upstream::HostDescriptionConstSharedPtr host) {
177177
upstream_handle_ = nullptr;
178178
callbacks_->onGenericPoolFailure(reason, host);

source/common/tcp_proxy/upstream.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class TcpConnPool : public GenericConnPool, public Tcp::ConnectionPool::Callback
2929

3030
// Tcp::ConnectionPool::Callbacks
3131
void onPoolFailure(ConnectionPool::PoolFailureReason reason,
32+
absl::string_view transport_failure_reason,
3233
Upstream::HostDescriptionConstSharedPtr host) override;
3334
void onPoolReady(Tcp::ConnectionPool::ConnectionDataPtr&& conn_data,
3435
Upstream::HostDescriptionConstSharedPtr host) override;

source/extensions/filters/network/dubbo_proxy/router/router_impl.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,7 @@ void Router::UpstreamRequest::encodeData(Buffer::Instance& data) {
281281
}
282282

283283
void Router::UpstreamRequest::onPoolFailure(ConnectionPool::PoolFailureReason reason,
284+
absl::string_view,
284285
Upstream::HostDescriptionConstSharedPtr host) {
285286
conn_pool_handle_ = nullptr;
286287

source/extensions/filters/network/dubbo_proxy/router/router_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class Router : public Tcp::ConnectionPool::UpstreamCallbacks,
6161

6262
// Tcp::ConnectionPool::Callbacks
6363
void onPoolFailure(ConnectionPool::PoolFailureReason reason,
64+
absl::string_view transport_failure_reason,
6465
Upstream::HostDescriptionConstSharedPtr host) override;
6566
void onPoolReady(Tcp::ConnectionPool::ConnectionDataPtr&& conn,
6667
Upstream::HostDescriptionConstSharedPtr host) override;

source/extensions/filters/network/rocketmq_proxy/router/router_impl.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ void RouterImpl::UpstreamRequest::onPoolReady(Tcp::ConnectionPool::ConnectionDat
166166
}
167167

168168
void RouterImpl::UpstreamRequest::onPoolFailure(Tcp::ConnectionPool::PoolFailureReason reason,
169+
absl::string_view,
169170
Upstream::HostDescriptionConstSharedPtr host) {
170171
if (router_.handle_) {
171172
ENVOY_LOG(trace, "#onPoolFailure, reset cancellable handle to nullptr");

source/extensions/filters/network/rocketmq_proxy/router/router_impl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ class RouterImpl : public Router, public Logger::Loggable<Logger::Id::rocketmq>
4141
UpstreamRequest(RouterImpl& router);
4242

4343
void onPoolFailure(Tcp::ConnectionPool::PoolFailureReason reason,
44+
absl::string_view transport_failure_reason,
4445
Upstream::HostDescriptionConstSharedPtr host) override;
4546

4647
void onPoolReady(Tcp::ConnectionPool::ConnectionDataPtr&& conn,

source/extensions/filters/network/thrift_proxy/router/router_impl.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -483,6 +483,7 @@ void Router::UpstreamRequest::releaseConnection(const bool close) {
483483
void Router::UpstreamRequest::resetStream() { releaseConnection(true); }
484484

485485
void Router::UpstreamRequest::onPoolFailure(ConnectionPool::PoolFailureReason reason,
486+
absl::string_view,
486487
Upstream::HostDescriptionConstSharedPtr host) {
487488
conn_pool_handle_ = nullptr;
488489

0 commit comments

Comments
 (0)