8000 chore(hyper): enable `deprecated` feature flag by cratelyn · Pull Request #3405 · linkerd/linkerd2-proxy · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

chore(hyper): enable deprecated feature flag #3405

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

Merged
merged 2 commits into from
Dec 3, 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
6 changes: 3 additions & 3 deletions Cargo.lock
Original file line number Diff line number Diff line change
Expand Up @@ -942,9 +942,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"

[[package]]
name = "hyper"
version = "0.14.28"
version = "0.14.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bf96e135eb83a2a8ddf766e426a841d8ddd7449d5f00d34ea02b41d2f19eef80"
checksum = "8c08302e8fa335b151b788c775ff56e7a03ae64ff85c548ee820fecb70356e85"
dependencies = [
"bytes",
"futures-channel",
Expand Down Expand Up @@ -1276,7 +1276,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
dependencies = [
"cfg-if",
"windows-targets 0.52.0",
"windows-targets 0.48.5",
]

[[package]]
Expand Down
2 changes: 1 addition & 1 deletion hyper-balance/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish = false
[dependencies]
futures = { version = "0.3", default-features = false }
http = "0.2"
hyper = "0.14"
hyper = { version = "0.14", features = ["deprecated"] }
pin-project = "1"
tower = { version = "0.4", default-features = false, features = ["load"] }
tokio = { version = "1", features = ["macros"] }
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ log-streaming = ["linkerd-tracing/stream"]
[dependencies]
deflate = { version = "1", optional = true, features = ["gzip"] }
http = "0.2"
hyper = { version = "0.14", features = ["http1", "http2"] }
hyper = { version = "0.14", features = ["deprecated", "http1", "http2"] }
futures = { version = "0.3", default-features = false }
pprof = { version = "0.14", optional = true, features = ["prost-codec"] }
serde = "1"
Expand Down
1 change: 1 addition & 0 deletions linkerd/app/admin/src/server/log/level.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ where
}

http::Method::PUT => {
#[allow(deprecated)] // linkerd/linkerd2#8733
let body = hyper::body::aggregate(req.into_body())
.await
.map_err(|e| io::Error::new(io::ErrorKind::Other, e))?;
Expand Down
1 change: 1 addition & 0 deletions linkerd/app/admin/src/server/log/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ where
// If the request is a QUERY, use the request body
method if method.as_str() == "QUERY" => {
// TODO(eliza): validate that the request has a content-length...
#[allow(deprecated)] // linkerd/linkerd2#8733
let body = recover!(
hyper::body::aggregate(req.into_body())
.await
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ bytes = "1"
drain = { version = "0.1", features = ["retain"] }
http = "0.2"
http-body = "0.4"
hyper = { version = "0.14", features = ["http1", "http2"] }
hyper = { version = "0.14", features = ["deprecated", "http1", "http2"] }
futures = { version = "0.3", default-features = false }
ipnet = "2.10"
prometheus-client = "0.22"
Expand Down
4 changes: 2 additions & 2 deletions linkerd/app/inbound/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ path = "../../proxy/server-policy"
features = ["proto"]

[target.'cfg(fuzzing)'.dependencies]
hyper = { version = "0.14", features = ["http1", "http2"] }
hyper = { version = "0.14", features = ["deprecated", "http1", "http2"] }
linkerd-app-test = { path = "../test" }
arbitrary = { version = "1", features = ["derive"] }
libfuzzer-sys = { version = "0.4", features = ["arbitrary-derive"] }

[dev-dependencies]
hyper = { version = "0.14", features = ["http1", "http2"] }
hyper = { version = "0.14", features = ["deprecated", "http1", "http2"] }
linkerd-app-test = { path = "../test" }
linkerd-http-metrics = { path = "../../http/metrics", features = ["test-util"] }
linkerd-idle-cache = { path = "../../idle-cache", features = ["test-util"] }
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/inbound/fuzz/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ cargo-fuzz = true

[target.'cfg(fuzzing)'.dependencies]
arbitrary = { version = "1", features = ["derive"] }
hyper = { version = "0.14", features = ["http1", "http2"] }
hyper = { version = "0.14", features = ["deprecated", "http1", "http2"] }
http = "0.2"
libfuzzer-sys = { version = "0.4", features = ["arbitrary-derive"] }
linkerd-app-core = { path = "../../core" }
Expand Down
47 changes: 34 additions & 13 deletions linkerd/app/inbound/src/http/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
},
Config, Inbound,
};
use hyper::{body::HttpBody, client::conn::Builder as ClientBuilder, Body, Request, Response};
use hyper::{body::HttpBody, Body, Request, Response};
use linkerd_app_core::{
classify,
errors::respond::L5D_PROXY_ERROR,
Expand Down Expand Up @@ -46,9 +46,11 @@ where

#[tokio::test(flavor = "current_thread")]
async fn unmeshed_http1_hello_world() {
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut server = hyper::server::conn::Http::new();
server.http1_only(true);
let mut client = ClientBuilder::new();
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut client = hyper::client::conn::Builder::new();
let _trace = trace_init();

// Build a mock "connector" that returns the upstream "server" IO.
Expand Down Expand Up @@ -82,9 +84,11 @@ async fn unmeshed_http1_hello_world() {
#[tokio::test(flavor = "current_thread")]
async fn downgrade_origin_form() {
// Reproduces https://github.com/linkerd/linkerd2/issues/5298
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut server = hyper::server::conn::Http::new();
server.http1_only(true);
let mut client = ClientBuilder::new();
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut client = hyper::client::conn::Builder::new();
client.http2_only(true);
let _trace = trace_init();

Expand Down Expand Up @@ -120,9 +124,11 @@ async fn downgrade_origin_form() {

#[tokio::test(flavor = "current_thread")]
async fn downgrade_absolute_form() {
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut server = hyper::server::conn::Http::new();
server.http1_only(true);
let mut client = ClientBuilder::new();
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut client = hyper::client::conn::Builder::new();
client.http2_only(true);
let _trace = trace_init();

Expand Down Expand Up @@ -165,7 +171,8 @@ async fn http1_bad_gateway_meshed_response_error_header() {

// Build a client using the connect that always errors so that responses
// are BAD_GATEWAY.
let mut client = ClientBuilder::new();
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut client = hyper::client::conn::Builder::new();
let profiles = profile::resolver();
let profile_tx =
profiles.profile_tx(NameAddr::from_str_and_port("foo.svc.cluster.local", 5550).unwrap());
Expand Down Expand Up @@ -203,7 +210,8 @@ async fn http1_bad_gateway_unmeshed_response() {

// Build a client using the connect that always errors so that responses
// are BAD_GATEWAY.
let mut client = ClientBuilder::new();
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut client = hyper::client::conn::Builder::new();
let profiles = profile::resolver();
let profile_tx =
profiles.profile_tx(NameAddr::from_str_and_port("foo.svc.cluster.local", 5550).unwrap());
Expand Down Expand Up @@ -238,12 +246,14 @@ async fn http1_connect_timeout_meshed_response_error_header() {

// Build a mock connect that sleeps longer than the default inbound
// connect timeout.
#[allow(deprecated)] // linkerd/linkerd2#8733
let server = hyper::server::conn::Http::new();
let connect = support::connect().endpoint(Target::addr(), connect_timeout(server));

// Build a client using the connect that always sleeps so that responses
// are GATEWAY_TIMEOUT.
let mut client = ClientBuilder::new();
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut client = hyper::client::conn::Builder::new();
let profiles = profile::resolver();
let profile_tx =
profiles.profile_tx(NameAddr::from_str_and_port("foo.svc.cluster.local", 5550).unwrap());
Expand Down Expand Up @@ -280,12 +290,14 @@ async fn http1_connect_timeout_unmeshed_response_error_header() {

// Build a mock connect that sleeps longer than the default inbound
// connect timeout.
#[allow(deprecated)] // linkerd/linkerd2#8733
let server = hyper::server::conn::Http::new();
let connect = support::connect().endpoint(Target::addr(), connect_timeout(server));

// Build a client using the connect that always sleeps so that responses
// are GATEWAY_TIMEOUT.
let mut client = ClientBuilder::new();
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut client = hyper::client::conn::Builder::new();
let profiles = profile::resolver();
let profile_tx =
profiles.profile_tx(NameAddr::from_str_and_port("foo.svc.cluster.local", 5550).unwrap());
Expand Down Expand Up @@ -321,7 +333,8 @@ async fn h2_response_meshed_error_header() {
let connect = support::connect().endpoint_fn_boxed(Target::addr(), connect_error());

// Build a client using the connect that always errors.
let mut client = ClientBuilder::new();
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut client = hyper::client::conn::Builder::new();
client.http2_only(true);
let profiles = profile::resolver();
let profile_tx =
Expand Down Expand Up @@ -359,7 +372,8 @@ async fn h2_response_unmeshed_error_header() {
let connect = support::connect().endpoint_fn_boxed(Target::addr(), connect_error());

// Build a client using the connect that always errors.
let mut client = ClientBuilder::new();
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut client = hyper::client::conn::Builder::new();
client.http2_only(true);
let profiles = profile::resolver();
let profile_tx =
Expand Down Expand Up @@ -399,7 +413,8 @@ async fn grpc_meshed_response_error_header() {
let connect = support::connect().endpoint_fn_boxed(Target::addr(), connect_error());

// Build a client using the connect that always errors.
let mut client = ClientBuilder::new();
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut client = hyper::client::conn::Builder::new();
client.http2_only(true);
let profiles = profile::resolver();
let profile_tx =
Expand Down Expand Up @@ -438,7 +453,8 @@ async fn grpc_unmeshed_response_error_header() {
let connect = support::connect().endpoint_fn_boxed(Target::addr(), connect_error());

// Build a client using the connect that always errors.
let mut client = ClientBuilder::new();
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut client = hyper::client::conn::Builder::new();
client.http2_only(true);
let profiles = profile::resolver();
let profile_tx =
Expand Down Expand Up @@ -477,6 +493,7 @@ async fn grpc_response_class() {

// Build a mock connector serves a gRPC server that returns errors.
let connect = {
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut server = hyper::server::conn::Http::new();
server.http2_only(true);
support::connect().endpoint_fn_boxed(
Expand All @@ -486,7 +503,8 @@ async fn grpc_response_class() {
};

// Build a client using the connect that always errors.
let mut client = ClientBuilder::new();
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut client = hyper::client::conn::Builder::new();
client.http2_only(true);
let profiles = profile::resolver();
let profile_tx =
Expand Down Expand Up @@ -550,6 +568,7 @@ async fn grpc_response_class() {
}

#[tracing::instrument]
#[allow(deprecated)] // linkerd/linkerd2#8733
fn hello_server(
http: hyper::server::conn::Http,
) -> impl Fn(Remote<ServerAddr>) -> io::Result<io::BoxedIo> {
Expand All @@ -571,6 +590,7 @@ fn hello_server(
}

#[tracing::instrument]
#[allow(deprecated)] // linkerd/linkerd2#8733
fn grpc_status_server(
http: hyper::server::conn::Http,
status: tonic::Code,
Expand Down Expand Up @@ -617,6 +637,7 @@ fn connect_error() -> impl Fn(Remote<ServerAddr>) -> io::Result<io::BoxedIo> {
}

#[tracing::instrument]
#[allow(deprecated)] // linkerd/linkerd2#8733
fn connect_timeout(
http: hyper::server::conn::Http,
) -> Box<dyn FnMut(Remote<ServerAddr>) -> ConnectFuture + Send> {
Expand Down
1 change: 1 addition & 0 deletions linkerd/app/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ h2 = "0.3"
http = "0.2"
http-body = "0.4"
hyper = { version = "0.14", features = [
"deprecated",
"http1",
"http2",
"stream",
Expand Down
1 change: 1 addition & 0 deletions linkerd/app/integration/src/controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,6 +372,7 @@ where
let _ = listening_tx.send(());
}

#[allow(deprecated)] // linkerd/linkerd2#8733
let mut http = hyper::server::conn::Http::new().with_executor(TracingExecutor);
http.http2_only(true);
loop {
Expand Down
1 change: 1 addition & 0 deletions linkerd/app/integration/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,7 @@ impl Server {
async move {
tracing::info!("support server running");
let mut new_svc = NewSvc(Arc::new(self.routes));
#[allow(deprecated)] // linkerd/linkerd2#8733
let mut http = hyper::server::conn::Http::new().with_executor(TracingExecutor);
match self.version {
Run::Http1 => http.http1_only(true),
Expand Down
1 change: 1 addition & 0 deletions linkerd/app/integration/src/tap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@ where
// just can't prove it.
let req = futures::executor::block_on(async move {
let (parts, body) = req.into_parts();
#[allow(deprecated)] // linkerd/linkerd2#8733
let body = match hyper::body::to_bytes(body).await {
Ok(body) => body,
Err(_) => unreachable!("body should not fail"),
Expand Down
20 changes: 10 additions & 10 deletions linkerd/app/integration/src/tests/discovery.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,16 +481,16 @@ mod http2 {

let res = fut.await.expect("beta response");
assert_eq!(res.status(), http::StatusCode::OK);
assert_eq!(
String::from_utf8(
hyper::body::to_bytes(res.into_body())
.await
.unwrap()
.to_vec(),
)
.unwrap(),
"beta"
);

#[allow(deprecated)] // linkerd/linkerd2#8733
let body = String::from_utf8(
hyper::body::to_bytes(res.into_body())
.await
.unwrap()
.to_vec(),
)
.unwrap();
assert_eq!(body, "beta");
}
}

Expand Down
1 change: 1 addition & 0 deletions linkerd/app/integration/src/tests/profiles.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ impl TestBuilder {
async move {
// Read the entire body before responding, so that the
// client doesn't fail when writing it out.
#[allow(deprecated)] // linkerd/linkerd2#8733
let _body = hyper::body::to_bytes(req.into_body()).await;
tracing::debug!(body = ?_body.as_ref().map(|body| body.len()), "recieved body");
Ok::<_, Error>(if fail {
Expand Down
13 changes: 8 additions & 5 deletions linkerd/app/integration/src/tests/shutdown.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ async fn h2_exercise_goaways_connections() {

let bodies = resps
.into_iter()
.map(|resp| {
hyper::body::aggregate(resp.into_body())
// Make sure the bodies weren't cut off
.map_ok(|buf| assert_eq!(buf.remaining(), RESPONSE_SIZE))
})
.map(
#[allow(deprecated)] // linkerd/linkerd2#8733
|resp| {
hyper::body::aggregate(resp.into_body())
// Make sure the bodies weren't cut off
.map_ok(|buf| assert_eq!(buf.remaining(), RESPONSE_SIZE))
},
)
.collect::<Vec<_>>();

// See that the proxy gives us all the bodies.
Expand Down
7 changes: 3 additions & 4 deletions linkerd/app/integration/src/tests/tap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,9 @@ async fn grpc_headers_end() {
.unwrap();
assert_eq!(res.status(), 200);
assert_eq!(res.headers()["grpc-status"], "1");
assert_eq!(
hyper::body::to_bytes(res.into_body()).await.unwrap().len(),
0
);
#[allow(deprecated)] // linkerd/linkerd2#8733
let bytes = hyper::body::to_bytes(res.into_body()).await.unwrap().len();
assert_eq!(bytes, 0);

let event = events.skip(2).next().await.expect("2nd").expect("stream");
assert_eq!(event.response_end_eos_grpc(), 1);
Expand Down
1 change: 1 addition & 0 deletions linkerd/app/integration/src/tests/telemetry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,7 @@ async fn metrics_compression() {
);
}

#[allow(deprecated)] // linkerd/linkerd2#8733
let mut body = hyper::body::aggregate(resp.into_body())
.await
.expect("response body concat");
Expand Down
1 change: 1 addition & 0 deletions linkerd/app/integration/src/tests/transparency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1601,6 +1601,7 @@ async fn http2_request_without_authority() {
let io = tokio::net::TcpStream::connect(&addr)
.await
.expect("connect error");
#[allow(deprecated)] // linkerd/linkerd2#8733
let (mut client, conn) = hyper::client::conn::Builder::new()
.http2_only(true)
.handshake(io)
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/outbound/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ linkerd-tonic-watch = { path = "../../tonic-watch" }
[dev-dependencies]
futures-util = "0.3"
http-body = "0.4"
hyper = { version = "0.14", features = ["http1", "http2"] }
hyper = { version = "0.14", features = ["deprecated", "http1", "http2"] }
tokio = { version = "1", features = ["macros", "sync", "time"] }
tokio-rustls = "0.24"
tokio-test = "0.4"
Expand Down
Loading
Loading
0