From 18e32e574eaa597c8ee046a721b82411be71688e Mon Sep 17 00:00:00 2001 From: Aviram Hassan Date: Thu, 6 Jun 2024 15:30:48 +0300 Subject: [PATCH] Fix HTTP2/1.1 translated messages dropping (#2498) * Fix HTTP2/1.1 translated messages dropping * apply it in the agent too --- changelog.d/2497.fixed.md | 1 + mirrord/agent/src/steal/connections/filtered.rs | 8 +++++++- mirrord/intproxy/src/proxies/incoming/http.rs | 11 +++++++---- 3 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 changelog.d/2497.fixed.md diff --git a/changelog.d/2497.fixed.md b/changelog.d/2497.fixed.md new file mode 100644 index 00000000000..4227e203bd0 --- /dev/null +++ b/changelog.d/2497.fixed.md @@ -0,0 +1 @@ +Fix HTTP2/1.1 translated messages dropping \ No newline at end of file diff --git a/mirrord/agent/src/steal/connections/filtered.rs b/mirrord/agent/src/steal/connections/filtered.rs index 3fd7a4cb27d..9dcc16b39e9 100644 --- a/mirrord/agent/src/steal/connections/filtered.rs +++ b/mirrord/agent/src/steal/connections/filtered.rs @@ -117,7 +117,7 @@ impl FilteringService { /// Also, it does not retry the request upon failure. async fn send_request( to: SocketAddr, - request: Request, + mut request: Request, ) -> Result, Box> { let tcp_stream = TcpStream::connect(to).await.inspect_err(|error| { tracing::error!(?error, address = %to, "Failed connecting to request destination"); @@ -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 diff --git a/mirrord/intproxy/src/proxies/incoming/http.rs b/mirrord/intproxy/src/proxies/incoming/http.rs index 63cf4d0239c..5fd4fb85c5c 100644 --- a/mirrord/intproxy/src/proxies/incoming/http.rs +++ b/mirrord/intproxy/src/proxies/incoming/http.rs @@ -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) } } }