Skip to content

Commit

Permalink
Fix HTTP2/1.1 translated messages dropping (#2498)
Browse files Browse the repository at this point in the history
* Fix HTTP2/1.1 translated messages dropping

* apply it in the agent too
  • Loading branch information
aviramha authored Jun 6, 2024
1 parent bae7524 commit 18e32e5
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
1 change: 1 addition & 0 deletions changelog.d/2497.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix HTTP2/1.1 translated messages dropping
8 changes: 7 additions & 1 deletion mirrord/agent/src/steal/connections/filtered.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ impl FilteringService {
/// Also, it does not retry the request upon failure.
async fn send_request(
to: SocketAddr,
request: Request<Incoming>,
mut request: Request<Incoming>,
) -> Result<Response<Incoming>, Box<dyn std::error::Error>> {
let tcp_stream = TcpStream::connect(to).await.inspect_err(|error| {
tracing::error!(?error, address = %to, "Failed connecting to request destination");
Expand All @@ -142,6 +142,12 @@ impl FilteringService {
}
});

// fixes https://github.com/metalbear-co/mirrord/issues/2497
// inspired by https://github.com/linkerd/linkerd2-proxy/blob/c5d9f1c1e7b7dddd9d75c0d1a0dca68188f38f34/linkerd/proxy/http/src/h2.rs#L175
if request.uri().authority().is_none() {
*request.version_mut() = hyper::http::Version::HTTP_11;
}

request_sender
.send_request(request)
.await
Expand Down
11 changes: 7 additions & 4 deletions mirrord/intproxy/src/proxies/incoming/http.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,16 @@ impl HttpSender {
.map_err(Into::into)
}
Self::V2(sender) => {
let mut req = req.into_hyper();
// fixes https://github.com/metalbear-co/mirrord/issues/2497
// inspired by https://github.com/linkerd/linkerd2-proxy/blob/c5d9f1c1e7b7dddd9d75c0d1a0dca68188f38f34/linkerd/proxy/http/src/h2.rs#L175
if req.uri().authority().is_none() {
*req.version_mut() = hyper::http::Version::HTTP_11;
}
// Solves a "connection was not ready" client error.
// https://rust-lang.github.io/wg-async/vision/submitted_stories/status_quo/barbara_tries_unix_socket.html#the-single-magical-line
sender.ready().await?;
sender
.send_request(req.into_hyper())
.await
.map_err(Into::into)
sender.send_request(req).await.map_err(Into::into)
}
}
}
Expand Down

0 comments on commit 18e32e5

Please sign in to comment.