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

chore(deps): upgrade to hyper 1.x #3504

Draft
wants to merge 14 commits into
base: main
Choose a base branch
from
Draft
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
603 changes: 360 additions & 243 deletions Cargo.lock

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,22 @@ lto = true

[workspace.dependencies]
bytes = { version = "1" }
h2 = { version = "0.3" }
http = { version = "0.2" }
http-body = { version = "0.4" }
hyper = { version = "0.14.32", default-features = false }
prost = { version = "0.12" }
prost-types = { version = "0.12" }
h2 = { version = "0.4" }
http = { version = "1" }
http-body = { version = "1" }
http-body-util = { version = "0.1" }
hyper = { version = "1", default-features = false }
hyper-util = { version = "0.1", default-features = false }
prost = { version = "0.13" }
prost-types = { version = "0.13" }
tokio-rustls = { version = "0.26", default-features = false, features = [
"ring",
"logging",
] }
tonic = { version = "0.10", default-features = false }
tonic-build = { version = "0.10", default-features = false }
tonic = { version = "0.12", default-features = false }
tonic-build = { version = "0.12", default-features = false }

[workspace.dependencies.linkerd2-proxy-api]
version = "0.15.0"
# git = "https://github.com/linkerd/linkerd2-proxy-api.git"
# branch = "main"
git = "https://github.com/linkerd/linkerd2-proxy-api.git"
rev = "981369a18918ce5570b2d49c329eca55ae831e87"
# https://github.com/linkerd/linkerd2-proxy-api/commit/981369a18918ce5570b2d49c329eca55ae831e87
2 changes: 1 addition & 1 deletion hyper-balance/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ publish = false
futures = { version = "0.3", default-features = false }
http = { workspace = true }
http-body = { workspace = true }
hyper = { workspace = true, features = ["deprecated"] }
hyper = { workspace = true }
pin-project = "1"
tower = { version = "0.4", default-features = false, features = ["load"] }
tokio = { version = "1", features = ["macros"] }
Expand Down
140 changes: 57 additions & 83 deletions hyper-balance/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,32 +102,20 @@ where
self.body.is_end_stream()
}

fn poll_data(
fn poll_frame(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Self::Data, Self::Error>>> {
) -> Poll<Option<Result<http_body::Frame<Self::Data>, Self::Error>>> {
let this = self.project();
let ret = futures::ready!(this.body.poll_data(cx));
let ret = futures::ready!(this.body.poll_frame(cx));

// Once a data frame is received, the handle is dropped. On subsequent calls, this
// Once a frame is received, the handle is dropped. On subsequent calls, this
// is a noop.
drop(this.handle.take());

Poll::Ready(ret)
}

fn poll_trailers(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
let this = self.project();
// If this is being called, the handle definitely should have been dropped
// already.
drop(this.handle.take());

this.body.poll_trailers(cx)
}

#[inline]
fn size_hint(&self) -> hyper::body::SizeHint {
self.body.size_hint()
Expand Down Expand Up @@ -157,35 +145,21 @@ impl<T: Send + 'static, B: Body> Body for PendingUntilEosBody<T, B> {
self.body.is_end_stream()
}

fn poll_data(
fn poll_frame(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Option<Result<Self::Data, Self::Error>>> {
) -> Poll<Option<Result<http_body::Frame<Self::Data>, Self::Error>>> {
let mut this = self.project();
let body = &mut this.body;
tokio::pin!(body);
let ret = futures::ready!(body.poll_data(cx));
let frame = futures::ready!(body.poll_frame(cx));

// If this was the last frame, then drop the handle immediately.
if this.body.is_end_stream() {
drop(this.handle.take());
}

Poll::Ready(ret)
}

fn poll_trailers(
self: Pin<&mut Self>,
cx: &mut Context<'_>,
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
let this = self.project();
let ret = futures::ready!(this.body.poll_trailers(cx));

// Once trailers are received, the handle is dropped immediately (in case the body
// is retained longer for some reason).
drop(this.handle.take());

Poll::Ready(ret)
Poll::Ready(frame)
}

#[inline]
Expand All @@ -198,7 +172,7 @@ impl<T: Send + 'static, B: Body> Body for PendingUntilEosBody<T, B> {
mod tests {
use super::{PendingUntilEos, PendingUntilFirstData};
use futures::future::poll_fn;
use http_body::Body;
use http_body::{Body, Frame};
use std::collections::VecDeque;
use std::io::Cursor;
use std::pin::Pin;
Expand All @@ -225,11 +199,13 @@ mod tests {
assert_ready!(task::spawn(poll_fn(|cx| {
let body = &mut body;
tokio::pin!(body);
body.poll_data(cx)
body.poll_frame(cx)
}))
.poll())
.expect("data some")
.expect("data ok");
.expect("frame is some")
.expect("frame is ok")
.into_data()
.expect("frame is data");
assert!(wk.upgrade().is_none());
}

Expand Down Expand Up @@ -282,10 +258,10 @@ mod tests {
let res = assert_ready!(task::spawn(poll_fn(|cx| {
let body = &mut body;
tokio::pin!(body);
body.poll_data(cx)
body.poll_frame(cx)
}))
.poll());
assert!(res.expect("data is some").is_err());
assert!(res.expect("frame is some").is_err());
assert!(wk.upgrade().is_none());
}

Expand All @@ -308,21 +284,21 @@ mod tests {
assert_ready!(task::spawn(poll_fn(|cx| {
let body = &mut body;
tokio::pin!(body);
body.poll_data(cx)
body.poll_frame(cx)
}))
.poll())
.expect("data some")
.expect("data ok");
.expect("frame is some")
.expect("frame is ok");
assert!(wk.upgrade().is_some());

assert_ready!(task::spawn(poll_fn(|cx| {
let body = &mut body;
tokio::pin!(body);
body.poll_data(cx)
body.poll_frame(cx)
}))
.poll())
.expect("data some")
.expect("data ok");
.expect("frame is some")
.expect("frame is ok");
assert!(wk.upgrade().is_none());
}

Expand Down Expand Up @@ -355,40 +331,42 @@ mod tests {
assert_ready!(task::spawn(poll_fn(|cx| {
let body = &mut body;
tokio::pin!(body);
body.poll_data(cx)
body.poll_frame(cx)
}))
.poll())
.expect("data")
.expect("data ok");
.expect("frame is some")
.expect("frame is ok");
assert!(wk.upgrade().is_some());

assert_ready!(task::spawn(poll_fn(|cx| {
let body = &mut body;
tokio::pin!(body);
body.poll_data(cx)
body.poll_frame(cx)
}))
.poll())
.expect("data")
.expect("data ok");
.expect("frame is some")
.expect("frame is ok");
assert!(wk.upgrade().is_some());

let poll = assert_ready!(task::spawn(poll_fn(|cx| {
assert_ready!(task::spawn(poll_fn(|cx| {
let body = &mut body;
tokio::pin!(body);
body.poll_data(cx)
body.poll_frame(cx)
}))
.poll());
assert!(poll.is_none());
assert!(wk.upgrade().is_some());
.poll())
.expect("frame is some")
.expect("frame is ok")
.into_trailers()
.expect("is trailers");
assert!(wk.upgrade().is_none());

assert_ready!(task::spawn(poll_fn(|cx| {
let poll = assert_ready!(task::spawn(poll_fn(|cx| {
let body = &mut body;
tokio::pin!(body);
body.poll_trailers(cx)
body.poll_frame(cx)
}))
.poll())
.expect("trailers ok")
.expect("trailers");
.poll());
assert!(poll.is_none());
assert!(wk.upgrade().is_none());
}

Expand All @@ -411,7 +389,7 @@ mod tests {
let poll = assert_ready!(task::spawn(poll_fn(|cx| {
let body = &mut body;
tokio::pin!(body);
body.poll_data(cx)
body.poll_frame(cx)
}))
.poll());
assert!(poll.expect("some").is_err());
Expand All @@ -437,20 +415,21 @@ mod tests {
self.0.is_empty() & self.1.is_none()
}

fn poll_data(
fn poll_frame(
mut self: Pin<&mut Self>,
_: &mut Context<'_>,
) -> Poll<Option<Result<Self::Data, Self::Error>>> {
Poll::Ready(self.as_mut().0.pop_front().map(Cursor::new).map(Ok))
}

fn poll_trailers(
mut self: Pin<&mut Self>,
_: &mut Context<'_>,
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
) -> Poll<Option<Result<http_body::Frame<Self::Data>, Self::Error>>> {
let mut this = self.as_mut();
assert!(this.0.is_empty());
Poll::Ready(Ok(this.1.take()))

// Return the next data frame from the sequence of chunks.
if let Some(chunk) = this.0.pop_front() {
let frame = Some(Ok(Frame::data(Cursor::new(chunk))));
return Poll::Ready(frame);
}

// Yield the trailers once all data frames have been yielded.
let trailers = this.1.take().map(Frame::<Self::Data>::trailers).map(Ok);
Poll::Ready(trailers)
}
}

Expand All @@ -464,18 +443,13 @@ mod tests {
self.0.is_none()
}

fn poll_data(
fn poll_frame(
mut self: Pin<&mut Self>,
_: &mut Context<'_>,
) -> Poll<Option<Result<Self::Data, Self::Error>>> {
Poll::Ready(Some(Err(self.as_mut().0.take().expect("err"))))
}
) -> Poll<Option<Result<http_body::Frame<Self::Data>, Self::Error>>> {
let err = self.as_mut().0.take().expect("err");

fn poll_trailers(
mut self: Pin<&mut Self>,
_: &mut Context<'_>,
) -> Poll<Result<Option<http::HeaderMap>, Self::Error>> {
Poll::Ready(Err(self.as_mut().0.take().expect("err")))
Poll::Ready(Some(Err(err)))
}
}
}
2 changes: 1 addition & 1 deletion linkerd/app/admin/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bytes = { workspace = true }
deflate = { version = "1", optional = true, features = ["gzip"] }
http = { workspace = true }
http-body = { workspace = true }
hyper = { workspace = true, features = ["deprecated", "http1", "http2"] }
hyper = { workspace = true, features = ["http1", "http2"] }
futures = { version = "0.3", default-features = false }
pprof = { version = "0.14", optional = true, features = ["prost-codec"] }
serde = "1"
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 = { workspace = true }
drain = { version = "0.1", features = ["retain"] }
http = { workspace = true }
http-body = { workspace = true }
hyper = { workspace = true, features = ["deprecated", "http1", "http2"] }
hyper = { workspace = true, features = ["http1", "http2"] }
futures = { version = "0.3", default-features = false }
ipnet = "2.11"
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,7 +45,7 @@ path = "../../proxy/server-policy"
features = ["proto"]

[target.'cfg(fuzzing)'.dependencies]
hyper = { workspace = true, features = ["deprecated", "http1", "http2"] }
hyper = { workspace = true, features = ["http1", "http2"] }
linkerd-app-test = { path = "../test" }
arbitrary = { version = "1", features = ["derive"] }
libfuzzer-sys = { version = "0.4", features = ["arbitrary-derive"] }
Expand All @@ -54,7 +54,7 @@ linkerd-meshtls-rustls = { path = "../../meshtls/rustls", features = [
] }

[dev-dependencies]
hyper = { workspace = true, features = ["deprecated", "http1", "http2"] }
hyper = { workspace = true, features = ["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
3 changes: 0 additions & 3 deletions linkerd/app/integration/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,8 @@ h2 = { workspace = true }
http = { workspace = true }
http-body = { workspace = true }
hyper = { workspace = true, features = [
"backports",
"deprecated",
"http1",
"http2",
"stream",
"client",
"server",
] }
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 @@ -54,7 +54,7 @@ linkerd-tonic-watch = { path = "../../tonic-watch" }
[dev-dependencies]
futures-util = "0.3"
http-body = { workspace = true }
hyper = { workspace = true, features = ["backports", "deprecated", "http1", "http2"] }
hyper = { workspace = true, features = ["http1", "http2"] }
tokio = { version = "1", features = ["macros", "sync", "time"] }
tokio-rustls = { workspace = true }
tokio-test = "0.4"
Expand Down
2 changes: 1 addition & 1 deletion linkerd/app/test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ futures = { version = "0.3", default-features = false }
h2 = { workspace = true }
http = { workspace = true }
http-body = { workspace = true }
hyper = { workspace = true, features = ["deprecated", "http1", "http2"] }
hyper = { workspace = true, features = ["http1", "http2"] }
linkerd-app-core = { path = "../core" }
linkerd-http-route = { path = "../../http/route", optional = true }
linkerd-identity = { path = "../../identity" }
Expand Down
Loading
Loading