diff --git a/Cargo.lock b/Cargo.lock index e18bb95474a30..b2175291e01b2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -131,18 +131,17 @@ checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26" [[package]] name = "axum" -version = "0.6.20" +version = "0.7.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b829e4e32b91e643de6eafe82b1d90675f5874230191a4ffbc1b336dec4d6bf" +checksum = "edca88bc138befd0323b20752846e6587272d3b03b0343c8ea28a6f819e6e71f" dependencies = [ "async-trait", "axum-core", - "bitflags 1.3.2", "bytes", "futures-util", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.32", + "http", + "http-body", + "http-body-util", "itoa", "matchit", "memchr", @@ -151,25 +150,28 @@ dependencies = [ "pin-project-lite", "rustversion", "serde", - "sync_wrapper 0.1.2", - "tower 0.4.13", + "sync_wrapper", + "tower 0.5.2", "tower-layer", "tower-service", ] [[package]] name = "axum-core" -version = "0.3.4" +version = "0.4.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "759fa577a247914fd3f7f76d62972792636412fbfd634cd452f6a385a74d2d2c" +checksum = "09f2bd6146b97ae3359fa0cc6d6b376d9539582c7b4220f041a33ec24c226199" dependencies = [ "async-trait", "bytes", "futures-util", - "http 0.2.12", - "http-body 0.4.6", + "http", + "http-body", + "http-body-util", "mime", + "pin-project-lite", "rustversion", + "sync_wrapper", "tower-layer", "tower-service", ] @@ -215,12 +217,6 @@ version = "0.22.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "72b3254f16251a8381aa12e40e3c4d2f0199f8c6508fbecb9d91f575e0fbb8c6" -[[package]] -name = "bitflags" -version = "1.3.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" - [[package]] name = "bitflags" version = "2.6.0" @@ -667,25 +663,6 @@ version = "0.31.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "07e28edb80900c19c28f1072f2e8aeca7fa06b23cd4169cefe1af5aa3260783f" -[[package]] -name = "h2" -version = "0.3.26" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81fe527a889e1532da5c525686d96d4c2e74cdd345badf8dfef9f6b39dd5f5e8" -dependencies = [ - "bytes", - "fnv", - "futures-core", - "futures-sink", - "futures-util", - "http 0.2.12", - "indexmap 2.2.6", - "slab", - "tokio", - "tokio-util", - "tracing", -] - [[package]] name = "h2" version = "0.4.7" @@ -697,7 +674,7 @@ dependencies = [ "fnv", "futures-core", "futures-sink", - "http 1.2.0", + "http", "indexmap 2.2.6", "slab", "tokio", @@ -737,7 +714,7 @@ dependencies = [ "base64 0.21.7", "bytes", "headers-core", - "http 1.2.0", + "http", "httpdate", "mime", "sha1", @@ -749,7 +726,7 @@ version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "54b4a22553d4242c49fddb9ba998a99962b5cc6f22cb5a3482bec22522403ce4" dependencies = [ - "http 1.2.0", + "http", ] [[package]] @@ -784,17 +761,6 @@ dependencies = [ "windows", ] -[[package]] -name = "http" -version = "0.2.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "601cbb57e577e2f5ef5be8e7b83f0f63994f25aa94d673e54a92d5c516d101f1" -dependencies = [ - "bytes", - "fnv", - "itoa", -] - [[package]] name = "http" version = "1.2.0" @@ -806,17 +772,6 @@ dependencies = [ "itoa", ] -[[package]] -name = "http-body" -version = "0.4.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ceab25649e9960c0311ea418d17bee82c0dcec1bd053b5f9a66e265a693bed2" -dependencies = [ - "bytes", - "http 0.2.12", - "pin-project-lite", -] - [[package]] name = "http-body" version = "1.0.1" @@ -824,7 +779,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1efedce1fb8e6913f23e0c92de8e62cd5b772a67e7b3946df930a62566c93184" dependencies = [ "bytes", - "http 1.2.0", + "http", ] [[package]] @@ -835,8 +790,8 @@ checksum = "793429d76616a256bcb62c2a2ec2bed781c8307e797e2598c50010f2bee2544f" dependencies = [ "bytes", "futures-util", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "pin-project-lite", ] @@ -852,30 +807,6 @@ version = "1.0.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "df3b46402a9d5adb4c86a0cf463f42e19994e3ee891101b1841f30a545cb49a9" -[[package]] -name = "hyper" -version = "0.14.32" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "41dfc780fdec9373c01bae43289ea34c972e40ee3c9f6b3c8801a35f35586ce7" -dependencies = [ - "bytes", - "futures-channel", - "futures-core", - "futures-util", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "httparse", - "httpdate", - "itoa", - "pin-project-lite", - "socket2", - "tokio", - "tower-service", - "tracing", - "want", -] - [[package]] name = "hyper" version = "1.5.2" @@ -885,9 +816,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "h2 0.4.7", - "http 1.2.0", - "http-body 1.0.1", + "h2", + "http", + "http-body", "httparse", "httpdate", "itoa", @@ -906,8 +837,8 @@ dependencies = [ "bytes", "futures-util", "headers", - "http 1.2.0", - "hyper 1.5.2", + "http", + "hyper", "hyper-rustls", "hyper-util", "pin-project-lite", @@ -923,8 +854,8 @@ version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "527d4d619ca2c2aafa31ec139a3d1d60bf557bf7578a1f20f743637eccd9ca19" dependencies = [ - "http 1.2.0", - "hyper 1.5.2", + "http", + "hyper", "hyper-util", "linked_hash_set", "once_cell", @@ -943,8 +874,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d191583f3da1305256f22463b9bb0471acad48a4e534a5218b9963e9c1f59b2" dependencies = [ "futures-util", - "http 1.2.0", - "hyper 1.5.2", + "http", + "hyper", "hyper-util", "log", "rustls", @@ -955,25 +886,13 @@ dependencies = [ "tower-service", ] -[[package]] -name = "hyper-timeout" -version = "0.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbb958482e8c7be4bc3cf272a766a2b0bf1a6755e7a6ae777f017a31d11b13b1" -dependencies = [ - "hyper 0.14.32", - "pin-project-lite", - "tokio", - "tokio-io-timeout", -] - [[package]] name = "hyper-timeout" version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2b90d566bffbce6a75bd8b09a05aa8c2cb1fabb6cb348f8840c9e4c90a0d83b0" dependencies = [ - "hyper 1.5.2", + "hyper", "hyper-util", "pin-project-lite", "tokio", @@ -989,9 +908,9 @@ dependencies = [ "bytes", "futures-channel", "futures-util", - "http 1.2.0", - "http-body 1.0.1", - "hyper 1.5.2", + "http", + "http-body", + "hyper", "pin-project-lite", "socket2", "tokio", @@ -1197,14 +1116,14 @@ dependencies = [ "either", "futures", "home", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "http-body-util", - "hyper 1.5.2", + "hyper", "hyper-http-proxy", "hyper-openssl", "hyper-rustls", - "hyper-timeout 0.5.2", + "hyper-timeout", "hyper-util", "jsonpath-rust", "k8s-openapi", @@ -1235,7 +1154,7 @@ checksum = "97aa830b288a178a90e784d1b0f1539f2d200d2188c7b4a3146d9dc983d596f3" dependencies = [ "chrono", "form_urlencoded", - "http 1.2.0", + "http", "json-patch", "k8s-openapi", "schemars", @@ -1302,7 +1221,7 @@ dependencies = [ "futures-core", "futures-util", "http-body-util", - "hyper 1.5.2", + "hyper", "hyper-util", "k8s-openapi", "kube-client", @@ -1396,7 +1315,7 @@ dependencies = [ "async-trait", "chrono", "futures", - "http 0.2.12", + "http", "ipnet", "regex", ] @@ -1409,8 +1328,8 @@ dependencies = [ "async-trait", "drain", "futures", - "http 0.2.12", - "hyper 1.5.2", + "http", + "hyper", "linkerd-policy-controller-core", "linkerd2-proxy-api", "maplit", @@ -1447,7 +1366,7 @@ dependencies = [ "anyhow", "chrono", "futures", - "http 0.2.12", + "http", "k8s-openapi", "kube", "kubert", @@ -1489,10 +1408,12 @@ version = "0.1.0" dependencies = [ "anyhow", "async-trait", + "bytes", "clap", "drain", "futures", - "hyper 1.5.2", + "http-body-util", + "hyper", "ipnet", "k8s-openapi", "kube", @@ -1512,6 +1433,7 @@ dependencies = [ "tokio", "tokio-stream", "tonic", + "tower 0.4.13", "tracing", ] @@ -1520,8 +1442,11 @@ name = "linkerd-policy-test" version = "0.1.0" dependencies = [ "anyhow", + "bytes", "futures", - "hyper 1.5.2", + "http-body-util", + "hyper", + "hyper-util", "ipnet", "k8s-gateway-api", "k8s-openapi", @@ -1539,6 +1464,7 @@ dependencies = [ "tokio", "tokio-test", "tonic", + "tower 0.4.13", "tracing", "tracing-subscriber", ] @@ -1546,14 +1472,13 @@ dependencies = [ [[package]] name = "linkerd2-proxy-api" version = "0.15.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4682c00263191a5bfa4fbe64f6d80b22ff2b49aaa294da5aac062f5abc6eb9e" +source = "git+https://github.com/linkerd/linkerd2-proxy-api?branch=ver%2Fdeps-http#eefd13348f239251139f577e878d583464f27be1" dependencies = [ - "http 0.2.12", + "http", "ipnet", "prost", "prost-types", - "thiserror 1.0.69", + "thiserror 2.0.9", "tonic", ] @@ -1672,7 +1597,7 @@ version = "0.10.68" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6174bc48f102d208783c2c84bf931bb75927a617866870de8a4ea85597f871f5" dependencies = [ - "bitflags 2.6.0", + "bitflags", "cfg-if", "foreign-types", "libc", @@ -1887,7 +1812,7 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "731e0d9356b0c25f16f33b5be79b1c57b562f141ebfcdb0ad8ac2c13a24293b4" dependencies = [ - "bitflags 2.6.0", + "bitflags", "hex", "lazy_static", "procfs-core", @@ -1900,7 +1825,7 @@ version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2d3554923a69f4ce04c4a754260c338f505ce22642d3830e049a399fc2059a29" dependencies = [ - "bitflags 2.6.0", + "bitflags", "hex", ] @@ -1929,9 +1854,9 @@ dependencies = [ [[package]] name = "prost" -version = "0.12.6" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "deb1435c188b76130da55f17a466d252ff7b1418b2ad3e037d127b94e3411f29" +checksum = "2c0fef6c4230e4ccf618a35c59d7ede15dea37de8427500f50aff708806e42ec" dependencies = [ "bytes", "prost-derive", @@ -1939,9 +1864,9 @@ dependencies = [ [[package]] name = "prost-derive" -version = "0.12.6" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" +checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" dependencies = [ "anyhow", "itertools", @@ -1952,9 +1877,9 @@ dependencies = [ [[package]] name = "prost-types" -version = "0.12.6" +version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9091c90b0a32608e984ff2fa4091273cbdd755d54935c51d520887f4a1dbd5b0" +checksum = "cc2f1e56baa61e93533aebc21af4d2134b70f66275e0fcdf3cbe43d77ff7e8fc" dependencies = [ "prost", ] @@ -2004,7 +1929,7 @@ version = "0.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "469052894dcb553421e483e4209ee581a45100d31b4018de03e5a7ad86374a7e" dependencies = [ - "bitflags 2.6.0", + "bitflags", ] [[package]] @@ -2078,7 +2003,7 @@ version = "0.38.38" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "aa260229e6538e52293eeb577aabd09945a09d6d9cc0fc550ed7529056c2e32a" dependencies = [ - "bitflags 2.6.0", + "bitflags", "errno", "libc", "linux-raw-sys", @@ -2217,7 +2142,7 @@ version = "2.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c627723fd09706bacdb5cf41499e95098555af3c3c29d014dc3c458ef6be11c0" dependencies = [ - "bitflags 2.6.0", + "bitflags", "core-foundation 0.9.4", "core-foundation-sys", "libc", @@ -2230,7 +2155,7 @@ version = "3.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81d3f8c9bfcc3cbb6b0179eb57042d75b1582bdc65c3cb95f3fa999509c03cbc" dependencies = [ - "bitflags 2.6.0", + "bitflags", "core-foundation 0.10.0", "core-foundation-sys", "libc", @@ -2413,12 +2338,6 @@ dependencies = [ "unicode-ident", ] -[[package]] -name = "sync_wrapper" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2047c6ded9c721764247e62cd3b03c09ffc529b2ba5b10ec482ae507a4a70160" - [[package]] name = "sync_wrapper" version = "1.0.2" @@ -2493,16 +2412,6 @@ dependencies = [ "windows-sys 0.52.0", ] -[[package]] -name = "tokio-io-timeout" -version = "1.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30b74022ada614a1b4834de765f9bb43877f910cc8ce4be40e89042c9223a8bf" -dependencies = [ - "pin-project-lite", - "tokio", -] - [[package]] name = "tokio-macros" version = "2.4.0" @@ -2589,23 +2498,26 @@ dependencies = [ [[package]] name = "tonic" -version = "0.10.2" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" +checksum = "877c5b330756d856ffcc4553ab34a5684481ade925ecc54bcd1bf02b1d0d4d52" dependencies = [ "async-stream", "async-trait", "axum", - "base64 0.21.7", + "base64 0.22.1", "bytes", - "h2 0.3.26", - "http 0.2.12", - "http-body 0.4.6", - "hyper 0.14.32", - "hyper-timeout 0.4.1", + "h2", + "http", + "http-body", + "http-body-util", + "hyper", + "hyper-timeout", + "hyper-util", "percent-encoding", "pin-project", "prost", + "socket2", "tokio", "tokio-stream", "tower 0.4.13", @@ -2643,7 +2555,7 @@ dependencies = [ "futures-core", "futures-util", "pin-project-lite", - "sync_wrapper 1.0.2", + "sync_wrapper", "tokio", "tokio-util", "tower-layer", @@ -2658,10 +2570,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "403fa3b783d4b626a8ad51d766ab03cb6d2dbfc46b1c5d4448395e6628dc9697" dependencies = [ "base64 0.22.1", - "bitflags 2.6.0", + "bitflags", "bytes", - "http 1.2.0", - "http-body 1.0.1", + "http", + "http-body", "mime", "pin-project-lite", "tower-layer", @@ -2771,7 +2683,7 @@ dependencies = [ "byteorder", "bytes", "data-encoding", - "http 1.2.0", + "http", "httparse", "log", "rand", diff --git a/Cargo.toml b/Cargo.toml index 3d33e22053ac4..bb35d291f06d9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -19,7 +19,15 @@ k8s-openapi = { version = "0.24", features = ["v1_31"] } kube = { version = "0.98", default-features = false } kubert = { version = "0.23.0-alpha5", default-features = false } +[workspace.dependencies.k8s-gateway-api] # TODO(ver): Remove this once we update to a proper generated version of the gateway api bindings. -k8s-gateway-api = { git = "https://github.com/linkerd/k8s-gateway-api-rs", features = [ - "experimental", -] } +git = "https://github.com/linkerd/k8s-gateway-api-rs" +features = ["experimental"] + +[workspace.dependencies.linkerd2-proxy-api] +git = "https://github.com/linkerd/linkerd2-proxy-api" +branch = "ver/deps-http" +features = [ + "inbound", + "outbound", +] diff --git a/policy-controller/core/Cargo.toml b/policy-controller/core/Cargo.toml index bd56b5adf2faa..adcba27ae214a 100644 --- a/policy-controller/core/Cargo.toml +++ b/policy-controller/core/Cargo.toml @@ -11,6 +11,6 @@ anyhow = "1" async-trait = "0.1" chrono = { version = "0.4.39", default-features = false } futures = { version = "0.3", default-features = false, features = ["std"] } -http = "0.2" +http = "1" ipnet = "2" regex = "1" diff --git a/policy-controller/grpc/Cargo.toml b/policy-controller/grpc/Cargo.toml index b25c1958d4151..91ecd03f6a1f1 100644 --- a/policy-controller/grpc/Cargo.toml +++ b/policy-controller/grpc/Cargo.toml @@ -8,19 +8,19 @@ publish = false [dependencies] async-stream = "0.3" async-trait = "0.1" -http = "0.2" +http = "1" drain = "0.1" futures = { version = "0.3", default-features = false } hyper = { version = "1", features = ["http2", "server"] } linkerd-policy-controller-core = { path = "../core" } maplit = "1" -prost-types = "0.12.6" +prost-types = "0.13" tokio = { version = "1", features = ["macros"] } -tonic = { version = "0.10", default-features = false } +tonic = { version = "0.12", default-features = false } tracing = "0.1" serde = { version = "1", features = ["derive"] } serde_json = "1" [dependencies.linkerd2-proxy-api] -version = "0.15" +workspace = true features = ["inbound", "outbound"] diff --git a/policy-controller/grpc/src/outbound/http.rs b/policy-controller/grpc/src/outbound/http.rs index 8f8e9d63d48dc..963e2b62c16bd 100644 --- a/policy-controller/grpc/src/outbound/http.rs +++ b/policy-controller/grpc/src/outbound/http.rs @@ -75,7 +75,7 @@ pub(crate) fn protocol( }), http1: Some(outbound::proxy_protocol::Http1 { routes: routes.clone(), - failure_accrual: accrual.clone(), + failure_accrual: accrual, }), http2: Some(outbound::proxy_protocol::Http2 { routes, diff --git a/policy-controller/k8s/index/Cargo.toml b/policy-controller/k8s/index/Cargo.toml index 7b0773eb7292f..8712d5b18ff0b 100644 --- a/policy-controller/k8s/index/Cargo.toml +++ b/policy-controller/k8s/index/Cargo.toml @@ -10,7 +10,7 @@ ahash = "0.8" anyhow = "1" chrono = { version = "0.4.39", default-features = false } futures = { version = "0.3", default-features = false } -http = "0.2" +http = "1" kube = { workspace = true, default-features = false, features = [ "client", "derive", diff --git a/policy-controller/runtime/Cargo.toml b/policy-controller/runtime/Cargo.toml index 68a652b5355d3..6e2f530e1bbac 100644 --- a/policy-controller/runtime/Cargo.toml +++ b/policy-controller/runtime/Cargo.toml @@ -16,9 +16,11 @@ rustls-tls = ["kube/rustls-tls"] [dependencies] anyhow = "1" async-trait = "0.1" +bytes = "1" drain = "0.1" futures = { version = "0.3", default-features = false } k8s-openapi = { workspace = true } +http-body-util = "0.1" hyper = { version = "1", features = ["http1", "http2", "server"] } ipnet = { version = "2", default-features = false } openssl = { version = "0.10.68", optional = true } @@ -28,6 +30,7 @@ serde = "1" serde_json = "1" thiserror = "2" tokio-stream = { version = "0.1", features = ["sync"] } +tower = "0.4" tracing = "0.1" regex = "1" @@ -66,6 +69,6 @@ version = "1" features = ["macros", "parking_lot", "rt", "rt-multi-thread", "signal"] [dependencies.tonic] -version = "0.10" +version = "0.12" default-features = false features = ["transport"] diff --git a/policy-controller/runtime/src/admission.rs b/policy-controller/runtime/src/admission.rs index c0f6f50afded0..f4455fd7cafeb 100644 --- a/policy-controller/runtime/src/admission.rs +++ b/policy-controller/runtime/src/admission.rs @@ -8,14 +8,15 @@ use crate::k8s::policy::{ }; use anyhow::{anyhow, bail, ensure, Context, Result}; use futures::future; -use hyper::{body::Buf, http, Body, Request, Response}; +use http_body_util::BodyExt; +use hyper::{http, Request, Response}; use k8s_openapi::api::core::v1::{Namespace, ServiceAccount}; use kube::{core::DynamicObject, Resource, ResourceExt}; use linkerd_policy_controller_core as core; use linkerd_policy_controller_k8s_api::gateway::{self as k8s_gateway_api, GrpcRoute}; use linkerd_policy_controller_k8s_index::{self as index, outbound::index as outbound_index}; use serde::de::DeserializeOwned; -use std::{collections::BTreeMap, task}; +use std::collections::BTreeMap; use thiserror::Error; use tracing::{debug, info, trace, warn}; @@ -49,31 +50,37 @@ trait Validate { ) -> Result<()>; } +type Body = http_body_util::Full; + // === impl AdmissionService === -impl hyper::service::Service> for Admission { +impl tower::Service> for Admission { type Response = Response; type Error = Error; type Future = future::BoxFuture<'static, Result, Error>>; - fn poll_ready(&mut self, _cx: &mut task::Context<'_>) -> task::Poll> { - task::Poll::Ready(Ok(())) + fn poll_ready( + &mut self, + _cx: &mut std::task::Context<'_>, + ) -> std::task::Poll> { + std::task::Poll::Ready(Ok(())) } - fn call(&mut self, req: Request) -> Self::Future { + fn call(&mut self, req: Request) -> Self::Future { trace!(?req); if req.method() != http::Method::POST || req.uri().path() != "/" { return Box::pin(future::ok( Response::builder() .status(http::StatusCode::NOT_FOUND) - .body(Body::empty()) + .body(Body::default()) .expect("not found response must be valid"), )); } let admission = self.clone(); Box::pin(async move { - let bytes = hyper::body::aggregate(req.into_body()).await?; + use bytes::Buf; + let bytes = req.into_body().collect().await?.to_bytes(); let review: Review = match serde_json::from_reader(bytes.reader()) { Ok(review) => review, Err(error) => { diff --git a/policy-controller/runtime/src/args.rs b/policy-controller/runtime/src/args.rs index b5861a66bbf27..6c177bb87b418 100644 --- a/policy-controller/runtime/src/args.rs +++ b/policy-controller/runtime/src/args.rs @@ -188,7 +188,7 @@ impl Args { kubert::LeaseParams { name: LEASE_NAME.to_string(), namespace: control_plane_namespace.clone(), - claimant: hostname, + claimant: hostname.clone(), lease_duration: LEASE_DURATION, renew_grace_period: RENEW_GRACE_PERIOD, field_manager: Some("policy-controller".into()), diff --git a/policy-test/Cargo.toml b/policy-test/Cargo.toml index 1761c1cd9c517..dfddcb21d9474 100644 --- a/policy-test/Cargo.toml +++ b/policy-test/Cargo.toml @@ -7,7 +7,10 @@ publish = false [dependencies] anyhow = "1" +bytes = "1" +http-body-util = "0.1" hyper = { version = "1", features = ["client", "http2"] } +hyper-util = { version = "0.1" } futures = { version = "0.3", default-features = false } ipnet = "2" k8s-gateway-api = { workspace = true } @@ -20,8 +23,9 @@ rand = "0.8" serde = "1" serde_json = "1" schemars = "0.8" -tonic = { version = "0.10", default-features = false } +tonic = { version = "0.12", default-features = false } tokio = { version = "1", features = ["macros", "rt"] } +tower = "0.4" tracing = "0.1" tracing-subscriber = { version = "0.3", features = ["env-filter"] } @@ -31,7 +35,7 @@ default-features = false features = ["client", "openssl-tls", "runtime", "ws"] [dependencies.linkerd2-proxy-api] -version = "0.15" +workspace = true features = ["inbound", "outbound"] [dev-dependencies] diff --git a/policy-test/src/grpc.rs b/policy-test/src/grpc.rs index b640c0b26724c..1903134ce8301 100644 --- a/policy-test/src/grpc.rs +++ b/policy-test/src/grpc.rs @@ -4,6 +4,7 @@ //! forwarding to connect to a running instance. use anyhow::Result; +use futures::{future, prelude::*}; pub use linkerd2_proxy_api::*; use linkerd2_proxy_api::{ inbound::inbound_server_policies_client::InboundServerPoliciesClient, @@ -105,7 +106,7 @@ pub struct OutboundPolicyClient { #[derive(Debug)] struct GrpcHttp { - tx: hyper::client::conn::SendRequest, + tx: hyper::client::conn::http2::SendRequest, } async fn get_policy_controller_pod(client: &kube::Client) -> Result { @@ -338,19 +339,21 @@ impl GrpcHttp { where I: io::AsyncRead + io::AsyncWrite + Unpin + Send + 'static, { - let (tx, conn) = hyper::client::conn::Builder::new() - .http2_only(true) - .handshake(io) - .await?; + let (tx, conn) = + hyper::client::conn::http2::Builder::new(hyper_util::rt::TokioExecutor::new()) + .handshake(hyper_util::rt::TokioIo::new(io)) + .await?; tokio::spawn(conn); Ok(Self { tx }) } } -impl hyper::service::Service> for GrpcHttp { - type Response = hyper::Response; +type Body = hyper::body::Incoming; + +impl tower::Service> for GrpcHttp { + type Response = hyper::Response; type Error = hyper::Error; - type Future = hyper::client::conn::ResponseFuture; + type Future = future::BoxFuture<'static, Result, hyper::Error>>; fn poll_ready( &mut self, @@ -371,7 +374,9 @@ impl hyper::service::Service> for GrpcHttp ); parts.uri = hyper::Uri::from_parts(uri).unwrap(); - self.tx.call(hyper::Request::from_parts(parts, body)) + self.tx + .send_request(hyper::Request::from_parts(parts, body)) + .boxed() } }