Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix HTTP2/1.1 translated messages dropping #2498

Merged
merged 2 commits into from
Jun 6, 2024
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
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
Loading