Skip to content

Commit 307dbc4

Browse files
authored
chore(hyper): address miscellaneous deprecations (#3444)
* chore(proxy/tap): address `Http` deprecation this is a trivial deprecation fix, for <linkerd/linkerd2#8733>. Signed-off-by: katelyn martin <[email protected]> * chore(app/outbound): address `Http` deprecation see <linkerd/linkerd2#8733>. this updates some test code to use the backported server connection interfaces. Signed-off-by: katelyn martin <[email protected]> * chore(app/integration): address `conn::Builder` deprecation this commit addresses uses of deprecated hyper interfaces in the `linkerd-app-integration` crate. see <linkerd/linkerd2#8733>. Signed-off-by: katelyn martin <[email protected]> * chore(app/inbound): remove stale `deprecated` allowance this was fixed in a previous commit. Signed-off-by: katelyn martin <[email protected]> --------- Signed-off-by: katelyn martin <[email protected]>
1 parent f31cf1f commit 307dbc4

File tree

9 files changed

+29
-31
lines changed

9 files changed

+29
-31
lines changed

linkerd/app/inbound/src/http/tests.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,6 @@ fn hello_server(
651651
}
652652

653653
#[tracing::instrument]
654-
#[allow(deprecated)] // linkerd/linkerd2#8733
655654
fn grpc_status_server(
656655
server: hyper::server::conn::http2::Builder<TracingExecutor>,
657656
status: tonic::Code,

linkerd/app/integration/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ h2 = "0.3"
2323
http = "0.2"
2424
http-body = "0.4"
2525
hyper = { version = "0.14", features = [
26+
"backports",
2627
"deprecated",
2728
"http1",
2829
"http2",

linkerd/app/integration/src/controller.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,9 +372,7 @@ where
372372
let _ = listening_tx.send(());
373373
}
374374

375-
#[allow(deprecated)] // linkerd/linkerd2#8733
376-
let mut http = hyper::server::conn::Http::new().with_executor(TracingExecutor);
377-
http.http2_only(true);
375+
let http = hyper::server::conn::http2::Builder::new(TracingExecutor);
378376
loop {
379377
let (sock, addr) = listener.accept().await?;
380378
let span = tracing::debug_span!("conn", %addr).or_current();

linkerd/app/integration/src/server.rs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,6 @@ impl Server {
194194
async move {
195195
tracing::info!("support server running");
196196
let mut new_svc = NewSvc(Arc::new(self.routes));
197-
#[allow(deprecated)] // linkerd/linkerd2#8733
198-
let mut http = hyper::server::conn::Http::new().with_executor(TracingExecutor);
199-
match self.version {
200-
Run::Http1 => http.http1_only(true),
201-
Run::Http2 => http.http2_only(true),
202-
};
203197
if let Some(delay) = delay {
204198
let _ = listening_tx.take().unwrap().send(());
205199
delay.await;
@@ -218,7 +212,6 @@ impl Server {
218212
let sock = accept_connection(sock, tls_config.clone())
219213
.instrument(span.clone())
220214
.await?;
221-
let http = http.clone();
222215
let srv_conn_count = srv_conn_count.clone();
223216
let svc = new_svc.call(());
224217
let f = async move {
@@ -229,10 +222,16 @@ impl Server {
229222
let svc = svc.map_err(|e| {
230223
tracing::error!("support/server new_service error: {}", e)
231224
})?;
232-
let result = http
233-
.serve_connection(sock, svc)
234-
.await
235-
.map_err(|e| tracing::error!("support/server error: {}", e));
225+
let result = match self.version {
226+
Run::Http1 => hyper::server::conn::http1::Builder::new()
227+
.serve_connection(sock, svc)
228+
.await
229+
.map_err(|e| tracing::error!("support/server error: {}", e)),
230+
Run::Http2 => hyper::server::conn::http2::Builder::new(TracingExecutor)
231+
.serve_connection(sock, svc)
232+
.await
233+
.map_err(|e| tracing::error!("support/server error: {}", e)),
234+
};
236235
tracing::trace!(?result, "serve done");
237236
result
238237
};

linkerd/app/integration/src/tests/transparency.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::*;
2+
use linkerd_app_core::svc::http::TracingExecutor;
23
use std::error::Error as _;
34
use tokio::time::timeout;
45

@@ -1601,9 +1602,7 @@ async fn http2_request_without_authority() {
16011602
let io = tokio::net::TcpStream::connect(&addr)
16021603
.await
16031604
.expect("connect error");
1604-
#[allow(deprecated)] // linkerd/linkerd2#8733
1605-
let (mut client, conn) = hyper::client::conn::Builder::new()
1606-
.http2_only(true)
1605+
let (mut client, conn) = hyper::client::conn::http2::Builder::new(TracingExecutor)
16071606
.handshake(io)
16081607
.await
16091608
.expect("handshake error");

linkerd/app/outbound/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ linkerd-tonic-watch = { path = "../../tonic-watch" }
5454
[dev-dependencies]
5555
futures-util = "0.3"
5656
http-body = "0.4"
57-
hyper = { version = "0.14", features = ["deprecated", "http1", "http2"] }
57+
hyper = { version = "0.14", features = ["backports", "deprecated", "http1", "http2"] }
5858
tokio = { version = "1", features = ["macros", "sync", "time"] }
5959
tokio-rustls = "0.24"
6060
tokio-test = "0.4"

linkerd/app/outbound/src/http/endpoint/tests.rs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use linkerd_app_core::metrics::OutboundZoneLocality;
55
use linkerd_app_core::{
66
io,
77
proxy::api_resolve::ProtocolHint,
8-
svc::{NewService, ServiceExt},
8+
svc::{http::TracingExecutor, NewService, ServiceExt},
99
Infallible,
1010
};
1111
use std::net::SocketAddr;
@@ -239,16 +239,21 @@ fn serve(version: ::http::Version) -> io::Result<io::BoxedIo> {
239239
future::ok::<_, Infallible>(rsp.body(hyper::Body::default()).unwrap())
240240
});
241241

242-
#[allow(deprecated)] // linkerd/linkerd2#8733
243-
let mut http = hyper::server::conn::Http::new();
242+
let (client_io, server_io) = io::duplex(4096);
244243
match version {
245-
::http::Version::HTTP_10 | ::http::Version::HTTP_11 => http.http1_only(true),
246-
::http::Version::HTTP_2 => http.http2_only(true),
244+
::http::Version::HTTP_10 | ::http::Version::HTTP_11 => {
245+
let http = hyper::server::conn::http1::Builder::new();
246+
let fut = http.serve_connection(server_io, svc);
247+
tokio::spawn(fut);
248+
}
249+
::http::Version::HTTP_2 => {
250+
let http = hyper::server::conn::http2::Builder::new(TracingExecutor);
251+
let fut = http.serve_connection(server_io, svc);
252+
tokio::spawn(fut);
253+
}
247254
_ => unreachable!("unsupported HTTP version {:?}", version),
248255
};
249256

250-
let (client_io, server_io) = io::duplex(4096);
251-
tokio::spawn(http.serve_connection(server_io, svc));
252257
Ok(io::BoxedIo::new(client_io))
253258
}
254259

linkerd/proxy/tap/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ publish = false
88

99
[dependencies]
1010
http = "0.2"
11-
hyper = { version = "0.14", features = ["deprecated", "http1", "http2"] }
11+
hyper = { version = "0.14", features = ["backports", "deprecated", "http1", "http2"] }
1212
futures = { version = "0.3", default-features = false }
1313
ipnet = "2.10"
1414
linkerd2-proxy-api = { workspace = true, features = ["tap"] }

linkerd/proxy/tap/src/accept.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,7 @@ impl AcceptPermittedClients {
4545
{
4646
let svc = TapServer::new(tap);
4747
Box::pin(async move {
48-
#[allow(deprecated)] // linkerd/linkerd2#8733
49-
hyper::server::conn::Http::new()
50-
.with_executor(TracingExecutor)
51-
.http2_only(true)
48+
hyper::server::conn::http2::Builder::new(TracingExecutor)
5249
.serve_connection(io, svc)
5350
.await
5451
.map_err(Into::into)

0 commit comments

Comments
 (0)