From 7c82fb177895466cde5a73e89de0bf27fab9f740 Mon Sep 17 00:00:00 2001 From: Oliver Gould Date: Mon, 4 Dec 2023 12:06:06 -0800 Subject: [PATCH] rust: Update to tonic v0.10 and prost v0.12 (#269) --- Cargo.lock | 144 ++++++++++++------------ Cargo.toml | 29 +++-- deny.toml | 4 +- proto/inbound.proto | 5 +- proto/outbound.proto | 5 +- src/gen/io.linkerd.proxy.destination.rs | 99 +++++++++++++--- src/gen/io.linkerd.proxy.http_route.rs | 4 +- src/gen/io.linkerd.proxy.identity.rs | 68 +++++++++-- src/gen/io.linkerd.proxy.inbound.rs | 107 +++++++++++++++--- src/gen/io.linkerd.proxy.outbound.rs | 100 +++++++++++++--- src/gen/io.linkerd.proxy.tap.rs | 67 +++++++++-- 11 files changed, 479 insertions(+), 153 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 093351b95..02cf49220 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3,32 +3,19 @@ version = 3 [[package]] -name = "anyhow" -version = "1.0.69" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" - -[[package]] -name = "async-stream" -version = "0.3.4" +name = "aho-corasick" +version = "1.1.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad445822218ce64be7a341abfb0b1ea43b5c23aa83902542a4542e78309d8e5e" +checksum = "b2969dcb958b36655471fc61f7e416fa76033bdd4bfed0678d8fee1e2d07a1f0" dependencies = [ - "async-stream-impl", - "futures-core", - "pin-project-lite", + "memchr", ] [[package]] -name = "async-stream-impl" -version = "0.3.4" +name = "anyhow" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e4655ae1a7b0cdf149156f780c5bf3f1352bc53cbd9e0a361a7ef7b22947e965" -dependencies = [ - "proc-macro2", - "quote", - "syn", -] +checksum = "224afbd727c3d6e4b90103ece64b8d1b67fbb1973b1046c2281eed3f3803f800" [[package]] name = "async-trait" @@ -38,7 +25,7 @@ checksum = "b84f9ebcc6c1f5b8cb160f6990096a5c127f423fcb6e1ccc46c370cbdfb75dfc" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -49,9 +36,9 @@ checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" [[package]] name = "base64" -version = "0.13.1" +version = "0.21.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +checksum = "35636a1494ede3b646cc98f74f8e62c773a38a659ebc777a2cf26b9b74171df9" [[package]] name = "bitflags" @@ -252,12 +239,6 @@ version = "1.0.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" -[[package]] -name = "lazy_static" -version = "1.4.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" - [[package]] name = "libc" version = "0.2.139" @@ -266,7 +247,7 @@ checksum = "201de327520df007757c1f0adce6e827fe8562fbc28bfd9c15571c66ca1f5f79" [[package]] name = "linkerd2-proxy-api" -version = "0.11.0" +version = "0.12.0" dependencies = [ "h2", "http", @@ -296,9 +277,9 @@ dependencies = [ [[package]] name = "memchr" -version = "2.5.0" +version = "2.6.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" +checksum = "f665ee40bc4a3c5590afb1e9677db74a508659dfd71e126420da8274909a0167" [[package]] name = "multimap" @@ -345,7 +326,7 @@ checksum = "069bdb1e05adc7a8990dce9cc75370895fbe4e3d58b9b73bf1aee56359344a55" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] @@ -362,28 +343,28 @@ checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" [[package]] name = "prettyplease" -version = "0.1.24" +version = "0.2.15" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4ebcd279d20a4a0a2404a33056388e950504d891c855c7975b9a8fef75f3bf04" +checksum = "ae005bd773ab59b4725093fd7df83fd7892f7d8eafb48dbd7de6e024e4215f9d" dependencies = [ "proc-macro2", - "syn", + "syn 2.0.39", ] [[package]] name = "proc-macro2" -version = "1.0.51" +version = "1.0.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5d727cae5b39d21da60fa540906919ad737832fe0b1c165da3a34d6548c849d6" +checksum = "39278fbbf5fb4f646ce651690877f89d1c5811a3d4acb27700c1cb3cdb78fd3b" dependencies = [ "unicode-ident", ] [[package]] name = "prost" -version = "0.11.9" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b82eaa1d779e9a4bc1c3217db8ffbeabaae1dca241bf70183242128d48681cd" +checksum = "146c289cda302b98a28d40c8b3b90498d6e526dd24ac2ecea73e4e491685b94a" dependencies = [ "bytes", "prost-derive", @@ -391,44 +372,44 @@ dependencies = [ [[package]] name = "prost-build" -version = "0.11.8" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2c828f93f5ca4826f97fedcbd3f9a536c16b12cff3dbbb4a007f932bbad95b12" +checksum = "c55e02e35260070b6f716a2423c2ff1c3bb1642ddca6f99e1f26d06268a0e2d2" dependencies = [ "bytes", "heck", "itertools", - "lazy_static", "log", "multimap", + "once_cell", "petgraph", "prettyplease", "prost", "prost-types", "regex", - "syn", + "syn 2.0.39", "tempfile", "which", ] [[package]] name = "prost-derive" -version = "0.11.9" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5d2d8d10f3c6ded6da8b05b5fb3b8a5082514344d56c9f871412d29b4e075b4" +checksum = "efb6c9a1dd1def8e2124d17e83a20af56f1570d6c2d2bd9e266ccb768df3840e" dependencies = [ "anyhow", "itertools", "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] name = "prost-types" -version = "0.11.8" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "379119666929a1afd7a043aa6cf96fa67a6dce9af60c88095a4686dbce4c9c88" +checksum = "193898f59edcf43c26227dcd4c8427f00d99d61e95dcde58dabd49fa291d470e" dependencies = [ "prost", ] @@ -444,9 +425,9 @@ dependencies = [ [[package]] name = "quote" -version = "1.0.23" +version = "1.0.33" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8856d8364d252a14d474036ea1358d63c9e6965c8e5c1885c18f73d70bff9c7b" +checksum = "5267fca4496028628a95160fc423a33e8b2e6af8a5302579e322e4b520293cae" dependencies = [ "proc-macro2", ] @@ -480,18 +461,32 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.1" +version = "1.10.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "380b951a9c5e80ddfd6136919eef32310721aa4aacd4889a8d39124b026ab343" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "48aaa5748ba571fb95cd2c85c09f629215d3a6ece942baa100950af03a34f733" +checksum = "5f804c7828047e88b2d32e2d7fe5a105da8ee3264f01902f796c8e067dc2483f" dependencies = [ + "aho-corasick", + "memchr", "regex-syntax", ] [[package]] name = "regex-syntax" -version = "0.6.28" +version = "0.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "456c603be3e8d448b072f410900c09faf164fbce2d480456f50eea6e25f9c848" +checksum = "c08c74e62047bb2de4ff487b251e4a92e24f48745648451635cec7d591162d9f" [[package]] name = "rustix" @@ -527,6 +522,17 @@ dependencies = [ "unicode-ident", ] +[[package]] +name = "syn" +version = "2.0.39" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "23e78b90f2fcf45d3e842032ce32e3f2d1545ba6636271dcbf24fa306d87be7a" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + [[package]] name = "tempfile" version = "3.4.0" @@ -542,22 +548,22 @@ dependencies = [ [[package]] name = "thiserror" -version = "1.0.39" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a5ab016db510546d856297882807df8da66a16fb8c4101cb8b30054b0d5b2d9c" +checksum = "f9a7210f5c9a7156bb50aa36aed4c95afb51df0df00713949448cf9e97d382d2" dependencies = [ "thiserror-impl", ] [[package]] name = "thiserror-impl" -version = "1.0.39" +version = "1.0.50" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5420d42e90af0c38c3290abcca25b9b3bdf379fc9f55c528f53a269d9c9a267e" +checksum = "266b2e40bc00e5a6c09c3584011e08b06f123c00362c92b975ba9843aaaa14b8" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -600,24 +606,20 @@ dependencies = [ [[package]] name = "tonic" -version = "0.8.3" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f219fad3b929bef19b1f86fbc0358d35daed8f2cac972037ac0dc10bbb8d5fb" +checksum = "d560933a0de61cf715926b9cac824d4c883c2c43142f787595e48280c40a1d0e" dependencies = [ - "async-stream", "async-trait", "base64", "bytes", - "futures-core", - "futures-util", "http", "http-body", "percent-encoding", "pin-project", "prost", - "prost-derive", + "tokio", "tokio-stream", - "tokio-util", "tower-layer", "tower-service", "tracing", @@ -625,15 +627,15 @@ dependencies = [ [[package]] name = "tonic-build" -version = "0.8.4" +version = "0.10.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5bf5e9b9c0f7e0a7c027dcfaba7b2c60816c7049171f679d99ee2ff65d0de8c4" +checksum = "9d021fc044c18582b9a2408cd0dd05b1596e3ecdb5c4df822bb0183545683889" dependencies = [ "prettyplease", "proc-macro2", "prost-build", "quote", - "syn", + "syn 2.0.39", ] [[package]] @@ -668,7 +670,7 @@ checksum = "4017f8f45139870ca7e672686113917c71c7a6e02d4924eda67186083c03081a" dependencies = [ "proc-macro2", "quote", - "syn", + "syn 1.0.109", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index e651fff55..64b40a15b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "linkerd2-proxy-api" -version = "0.11.0" +version = "0.12.0" authors = ["Linkerd Developers "] license = "Apache-2.0" edition = "2021" @@ -19,8 +19,23 @@ grpc-route = ["http-route"] http-route = ["http-types"] http-types = ["http", "thiserror"] identity = ["prost-types", "tonic/codegen"] -inbound = ["grpc-route", "http-route", "meta", "net", "prost-types", "tonic/codegen"] -outbound = ["grpc-route", "destination", "http-route", "meta", "net", "prost-types", "tonic/codegen"] +inbound = [ + "grpc-route", + "http-route", + "meta", + "net", + "prost-types", + "tonic/codegen", +] +outbound = [ + "grpc-route", + "destination", + "http-route", + "meta", + "net", + "prost-types", + "tonic/codegen", +] meta = [] net = ["ipnet", "thiserror"] tap = ["h2", "http-types", "net", "prost-types", "tonic/codegen"] @@ -33,17 +48,17 @@ all-features = true h2 = { version = "0.3", optional = true } http = { version = "0.2", optional = true } ipnet = { version = "2", optional = true } -prost = "0.11" -prost-types = { version = "0.11", optional = true } +prost = "0.12" +prost-types = { version = "0.12", optional = true } quickcheck = { version = "1", default-features = false, optional = true } thiserror = { version = "1", optional = true } [dependencies.tonic] -version = "0.8" +version = "0.10" default-features = false features = ["prost"] [dev-dependencies.tonic-build] -version = "0.8" +version = "0.10" default-features = false features = ["prost"] diff --git a/deny.toml b/deny.toml index cc4b87204..a2fa66914 100644 --- a/deny.toml +++ b/deny.toml @@ -43,7 +43,9 @@ multiple-versions = "deny" wildcards = "allow" highlight = "all" deny = [] -skip = [] +skip = [ + { name = "syn" }, +] skip-tree = [] [sources] diff --git a/proto/inbound.proto b/proto/inbound.proto index 3a1538f02..afde04301 100644 --- a/proto/inbound.proto +++ b/proto/inbound.proto @@ -178,9 +178,8 @@ message Identity { string name = 1; } // "bar"]` is equivalent to "foo.bar." (matching `*.foo.bar`), etc. message IdentitySuffix { repeated string parts = 1; } -// Inbound-specific HTTP route configuration (based on the [Gateway API][api]). -// -// [api]: https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.HTTPRoute +// Inbound-specific HTTP route configuration (based on the +// [Gateway API](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.HTTPRoute)). message HttpRoute { io.linkerd.proxy.meta.Metadata metadata = 1; diff --git a/proto/outbound.proto b/proto/outbound.proto index a8528b2b6..fd2df06d4 100644 --- a/proto/outbound.proto +++ b/proto/outbound.proto @@ -95,9 +95,8 @@ message ProxyProtocol { } } -// Outbound-specific HTTP route configuration (based on the [Gateway API][api]). -// -// [api]: https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.HTTPRoute +// Outbound-specific HTTP route configuration (based on the +// [Gateway API](https://gateway-api.sigs.k8s.io/v1alpha2/references/spec/#gateway.networking.k8s.io/v1alpha2.HTTPRoute)). message HttpRoute { io.linkerd.proxy.meta.Metadata metadata = 1; diff --git a/src/gen/io.linkerd.proxy.destination.rs b/src/gen/io.linkerd.proxy.destination.rs index fbd917cb2..4630a6ee9 100644 --- a/src/gen/io.linkerd.proxy.destination.rs +++ b/src/gen/io.linkerd.proxy.destination.rs @@ -410,12 +410,28 @@ pub mod destination_client { self.inner = self.inner.accept_compressed(encoding); self } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } /// Given a destination, return all addresses in that destination as a long- /// running stream of updates. pub async fn get( &mut self, request: impl tonic::IntoRequest, - ) -> Result< + ) -> std::result::Result< tonic::Response>, tonic::Status, > { @@ -432,14 +448,19 @@ pub mod destination_client { let path = http::uri::PathAndQuery::from_static( "/io.linkerd.proxy.destination.Destination/Get", ); - self.inner.server_streaming(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("io.linkerd.proxy.destination.Destination", "Get"), + ); + self.inner.server_streaming(req, path, codec).await } /// Given a destination, return that destination's profile and send an update /// whenever it changes. pub async fn get_profile( &mut self, request: impl tonic::IntoRequest, - ) -> Result< + ) -> std::result::Result< tonic::Response>, tonic::Status, > { @@ -456,7 +477,15 @@ pub mod destination_client { let path = http::uri::PathAndQuery::from_static( "/io.linkerd.proxy.destination.Destination/GetProfile", ); - self.inner.server_streaming(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "io.linkerd.proxy.destination.Destination", + "GetProfile", + ), + ); + self.inner.server_streaming(req, path, codec).await } } } @@ -468,7 +497,9 @@ pub mod destination_server { #[async_trait] pub trait Destination: Send + Sync + 'static { /// Server streaming response type for the Get method. - type GetStream: futures_core::Stream> + type GetStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, + > + Send + 'static; /// Given a destination, return all addresses in that destination as a long- @@ -476,10 +507,10 @@ pub mod destination_server { async fn get( &self, request: tonic::Request, - ) -> Result, tonic::Status>; + ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the GetProfile method. - type GetProfileStream: futures_core::Stream< - Item = Result, + type GetProfileStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, > + Send + 'static; @@ -488,13 +519,15 @@ pub mod destination_server { async fn get_profile( &self, request: tonic::Request, - ) -> Result, tonic::Status>; + ) -> std::result::Result, tonic::Status>; } #[derive(Debug)] pub struct DestinationServer { inner: _Inner, accept_compression_encodings: EnabledCompressionEncodings, send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, } struct _Inner(Arc); impl DestinationServer { @@ -507,6 +540,8 @@ pub mod destination_server { inner, accept_compression_encodings: Default::default(), send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, } } pub fn with_interceptor( @@ -530,6 +565,22 @@ pub mod destination_server { self.send_compression_encodings.enable(encoding); self } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } } impl tonic::codegen::Service> for DestinationServer where @@ -543,7 +594,7 @@ pub mod destination_server { fn poll_ready( &mut self, _cx: &mut Context<'_>, - ) -> Poll> { + ) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { @@ -566,13 +617,17 @@ pub mod destination_server { &mut self, request: tonic::Request, ) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).get(request).await }; + let inner = Arc::clone(&self.0); + let fut = async move { + ::get(&inner, request).await + }; Box::pin(fut) } } let accept_compression_encodings = self.accept_compression_encodings; let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; let inner = self.inner.clone(); let fut = async move { let inner = inner.0; @@ -582,6 +637,10 @@ pub mod destination_server { .apply_compression_config( accept_compression_encodings, send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, ); let res = grpc.server_streaming(method, req).await; Ok(res) @@ -605,13 +664,17 @@ pub mod destination_server { &mut self, request: tonic::Request, ) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).get_profile(request).await }; + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_profile(&inner, request).await + }; Box::pin(fut) } } let accept_compression_encodings = self.accept_compression_encodings; let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; let inner = self.inner.clone(); let fut = async move { let inner = inner.0; @@ -621,6 +684,10 @@ pub mod destination_server { .apply_compression_config( accept_compression_encodings, send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, ); let res = grpc.server_streaming(method, req).await; Ok(res) @@ -649,12 +716,14 @@ pub mod destination_server { inner, accept_compression_encodings: self.accept_compression_encodings, send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, } } } impl Clone for _Inner { fn clone(&self) -> Self { - Self(self.0.clone()) + Self(Arc::clone(&self.0)) } } impl std::fmt::Debug for _Inner { diff --git a/src/gen/io.linkerd.proxy.http_route.rs b/src/gen/io.linkerd.proxy.http_route.rs index 687f72962..626158284 100644 --- a/src/gen/io.linkerd.proxy.http_route.rs +++ b/src/gen/io.linkerd.proxy.http_route.rs @@ -7,7 +7,7 @@ pub struct HostMatch { } /// Nested message and enum types in `HostMatch`. pub mod host_match { - /// A match like `*.example.com` is encoded as [com, example]. + /// A match like `*.example.com` is encoded as \[com, example\]. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Suffix { @@ -212,7 +212,7 @@ pub struct HttpFailureInjector { } /// A ratio (i.e., of requests) to which an filter should be applied. /// -/// Represents fractional values on [0, 1]. +/// Represents fractional values on \[0, 1\]. #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct Ratio { diff --git a/src/gen/io.linkerd.proxy.identity.rs b/src/gen/io.linkerd.proxy.identity.rs index fcaf980ee..091122e39 100644 --- a/src/gen/io.linkerd.proxy.identity.rs +++ b/src/gen/io.linkerd.proxy.identity.rs @@ -86,6 +86,22 @@ pub mod identity_client { self.inner = self.inner.accept_compressed(encoding); self } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } /// Requests that a time-bounded certificate be signed. /// /// The requester must provide a token that verifies the client's identity and @@ -96,7 +112,10 @@ pub mod identity_client { pub async fn certify( &mut self, request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { + ) -> std::result::Result< + tonic::Response, + tonic::Status, + > { self.inner .ready() .await @@ -110,7 +129,12 @@ pub mod identity_client { let path = http::uri::PathAndQuery::from_static( "/io.linkerd.proxy.identity.Identity/Certify", ); - self.inner.unary(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("io.linkerd.proxy.identity.Identity", "Certify"), + ); + self.inner.unary(req, path, codec).await } } } @@ -131,13 +155,15 @@ pub mod identity_server { async fn certify( &self, request: tonic::Request, - ) -> Result, tonic::Status>; + ) -> std::result::Result, tonic::Status>; } #[derive(Debug)] pub struct IdentityServer { inner: _Inner, accept_compression_encodings: EnabledCompressionEncodings, send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, } struct _Inner(Arc); impl IdentityServer { @@ -150,6 +176,8 @@ pub mod identity_server { inner, accept_compression_encodings: Default::default(), send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, } } pub fn with_interceptor( @@ -173,6 +201,22 @@ pub mod identity_server { self.send_compression_encodings.enable(encoding); self } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } } impl tonic::codegen::Service> for IdentityServer where @@ -186,7 +230,7 @@ pub mod identity_server { fn poll_ready( &mut self, _cx: &mut Context<'_>, - ) -> Poll> { + ) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { @@ -206,13 +250,17 @@ pub mod identity_server { &mut self, request: tonic::Request, ) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).certify(request).await }; + let inner = Arc::clone(&self.0); + let fut = async move { + ::certify(&inner, request).await + }; Box::pin(fut) } } let accept_compression_encodings = self.accept_compression_encodings; let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; let inner = self.inner.clone(); let fut = async move { let inner = inner.0; @@ -222,6 +270,10 @@ pub mod identity_server { .apply_compression_config( accept_compression_encodings, send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, ); let res = grpc.unary(method, req).await; Ok(res) @@ -250,12 +302,14 @@ pub mod identity_server { inner, accept_compression_encodings: self.accept_compression_encodings, send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, } } } impl Clone for _Inner { fn clone(&self) -> Self { - Self(self.0.clone()) + Self(Arc::clone(&self.0)) } } impl std::fmt::Debug for _Inner { diff --git a/src/gen/io.linkerd.proxy.inbound.rs b/src/gen/io.linkerd.proxy.inbound.rs index 880010808..312ab3de8 100644 --- a/src/gen/io.linkerd.proxy.inbound.rs +++ b/src/gen/io.linkerd.proxy.inbound.rs @@ -101,7 +101,7 @@ pub struct Authz { /// /// Must have at least one network, otherwise the authorization must be /// ignored. An authorization matches all clients by including an explicit - /// match on, i.e., `[0.0.0.0/0, 0::/0]``. + /// match on, i.e., `\[0.0.0.0/0, 0::/0\]``. #[prost(message, repeated, tag = "1")] pub networks: ::prost::alloc::vec::Vec, /// Must be set. @@ -203,9 +203,8 @@ pub struct IdentitySuffix { #[prost(string, repeated, tag = "1")] pub parts: ::prost::alloc::vec::Vec<::prost::alloc::string::String>, } -/// Inbound-specific HTTP route configuration (based on the [Gateway API]\[api\]). -/// -/// \[api\]: +/// Inbound-specific HTTP route configuration (based on the +/// [Gateway API]()). #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct HttpRoute { @@ -366,11 +365,27 @@ pub mod inbound_server_policies_client { self.inner = self.inner.accept_compressed(encoding); self } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } /// / Gets the inbound server policy for a given workload port. pub async fn get_port( &mut self, request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -384,13 +399,21 @@ pub mod inbound_server_policies_client { let path = http::uri::PathAndQuery::from_static( "/io.linkerd.proxy.inbound.InboundServerPolicies/GetPort", ); - self.inner.unary(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "io.linkerd.proxy.inbound.InboundServerPolicies", + "GetPort", + ), + ); + self.inner.unary(req, path, codec).await } /// / Watches the inbound server policy for a given workload port. pub async fn watch_port( &mut self, request: impl tonic::IntoRequest, - ) -> Result< + ) -> std::result::Result< tonic::Response>, tonic::Status, > { @@ -407,7 +430,15 @@ pub mod inbound_server_policies_client { let path = http::uri::PathAndQuery::from_static( "/io.linkerd.proxy.inbound.InboundServerPolicies/WatchPort", ); - self.inner.server_streaming(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "io.linkerd.proxy.inbound.InboundServerPolicies", + "WatchPort", + ), + ); + self.inner.server_streaming(req, path, codec).await } } } @@ -422,10 +453,10 @@ pub mod inbound_server_policies_server { async fn get_port( &self, request: tonic::Request, - ) -> Result, tonic::Status>; + ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the WatchPort method. - type WatchPortStream: futures_core::Stream< - Item = Result, + type WatchPortStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, > + Send + 'static; @@ -433,7 +464,7 @@ pub mod inbound_server_policies_server { async fn watch_port( &self, request: tonic::Request, - ) -> Result, tonic::Status>; + ) -> std::result::Result, tonic::Status>; } /// / An API exposed to the linkerd2-proxy to configure the inbound proxy with per-port configuration /// / @@ -447,6 +478,8 @@ pub mod inbound_server_policies_server { inner: _Inner, accept_compression_encodings: EnabledCompressionEncodings, send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, } struct _Inner(Arc); impl InboundServerPoliciesServer { @@ -459,6 +492,8 @@ pub mod inbound_server_policies_server { inner, accept_compression_encodings: Default::default(), send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, } } pub fn with_interceptor( @@ -482,6 +517,22 @@ pub mod inbound_server_policies_server { self.send_compression_encodings.enable(encoding); self } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } } impl tonic::codegen::Service> for InboundServerPoliciesServer @@ -496,7 +547,7 @@ pub mod inbound_server_policies_server { fn poll_ready( &mut self, _cx: &mut Context<'_>, - ) -> Poll> { + ) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { @@ -517,13 +568,18 @@ pub mod inbound_server_policies_server { &mut self, request: tonic::Request, ) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).get_port(request).await }; + let inner = Arc::clone(&self.0); + let fut = async move { + ::get_port(&inner, request) + .await + }; Box::pin(fut) } } let accept_compression_encodings = self.accept_compression_encodings; let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; let inner = self.inner.clone(); let fut = async move { let inner = inner.0; @@ -533,6 +589,10 @@ pub mod inbound_server_policies_server { .apply_compression_config( accept_compression_encodings, send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, ); let res = grpc.unary(method, req).await; Ok(res) @@ -556,13 +616,18 @@ pub mod inbound_server_policies_server { &mut self, request: tonic::Request, ) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).watch_port(request).await }; + let inner = Arc::clone(&self.0); + let fut = async move { + ::watch_port(&inner, request) + .await + }; Box::pin(fut) } } let accept_compression_encodings = self.accept_compression_encodings; let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; let inner = self.inner.clone(); let fut = async move { let inner = inner.0; @@ -572,6 +637,10 @@ pub mod inbound_server_policies_server { .apply_compression_config( accept_compression_encodings, send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, ); let res = grpc.server_streaming(method, req).await; Ok(res) @@ -600,12 +669,14 @@ pub mod inbound_server_policies_server { inner, accept_compression_encodings: self.accept_compression_encodings, send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, } } } impl Clone for _Inner { fn clone(&self) -> Self { - Self(self.0.clone()) + Self(Arc::clone(&self.0)) } } impl std::fmt::Debug for _Inner { diff --git a/src/gen/io.linkerd.proxy.outbound.rs b/src/gen/io.linkerd.proxy.outbound.rs index a0d4f723b..e5c62e4e0 100644 --- a/src/gen/io.linkerd.proxy.outbound.rs +++ b/src/gen/io.linkerd.proxy.outbound.rs @@ -110,9 +110,8 @@ pub mod proxy_protocol { Grpc(Grpc), } } -/// Outbound-specific HTTP route configuration (based on the [Gateway API]\[api\]). -/// -/// \[api\]: +/// Outbound-specific HTTP route configuration (based on the +/// [Gateway API]()). #[allow(clippy::derive_partial_eq_without_eq)] #[derive(Clone, PartialEq, ::prost::Message)] pub struct HttpRoute { @@ -596,10 +595,26 @@ pub mod outbound_policies_client { self.inner = self.inner.accept_compressed(encoding); self } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } pub async fn get( &mut self, request: impl tonic::IntoRequest, - ) -> Result, tonic::Status> { + ) -> std::result::Result, tonic::Status> { self.inner .ready() .await @@ -613,12 +628,17 @@ pub mod outbound_policies_client { let path = http::uri::PathAndQuery::from_static( "/io.linkerd.proxy.outbound.OutboundPolicies/Get", ); - self.inner.unary(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new("io.linkerd.proxy.outbound.OutboundPolicies", "Get"), + ); + self.inner.unary(req, path, codec).await } pub async fn watch( &mut self, request: impl tonic::IntoRequest, - ) -> Result< + ) -> std::result::Result< tonic::Response>, tonic::Status, > { @@ -635,7 +655,15 @@ pub mod outbound_policies_client { let path = http::uri::PathAndQuery::from_static( "/io.linkerd.proxy.outbound.OutboundPolicies/Watch", ); - self.inner.server_streaming(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert( + GrpcMethod::new( + "io.linkerd.proxy.outbound.OutboundPolicies", + "Watch", + ), + ); + self.inner.server_streaming(req, path, codec).await } } } @@ -649,23 +677,25 @@ pub mod outbound_policies_server { async fn get( &self, request: tonic::Request, - ) -> Result, tonic::Status>; + ) -> std::result::Result, tonic::Status>; /// Server streaming response type for the Watch method. - type WatchStream: futures_core::Stream< - Item = Result, + type WatchStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, > + Send + 'static; async fn watch( &self, request: tonic::Request, - ) -> Result, tonic::Status>; + ) -> std::result::Result, tonic::Status>; } #[derive(Debug)] pub struct OutboundPoliciesServer { inner: _Inner, accept_compression_encodings: EnabledCompressionEncodings, send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, } struct _Inner(Arc); impl OutboundPoliciesServer { @@ -678,6 +708,8 @@ pub mod outbound_policies_server { inner, accept_compression_encodings: Default::default(), send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, } } pub fn with_interceptor( @@ -701,6 +733,22 @@ pub mod outbound_policies_server { self.send_compression_encodings.enable(encoding); self } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } } impl tonic::codegen::Service> for OutboundPoliciesServer where @@ -714,7 +762,7 @@ pub mod outbound_policies_server { fn poll_ready( &mut self, _cx: &mut Context<'_>, - ) -> Poll> { + ) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { @@ -735,13 +783,17 @@ pub mod outbound_policies_server { &mut self, request: tonic::Request, ) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).get(request).await }; + let inner = Arc::clone(&self.0); + let fut = async move { + ::get(&inner, request).await + }; Box::pin(fut) } } let accept_compression_encodings = self.accept_compression_encodings; let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; let inner = self.inner.clone(); let fut = async move { let inner = inner.0; @@ -751,6 +803,10 @@ pub mod outbound_policies_server { .apply_compression_config( accept_compression_encodings, send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, ); let res = grpc.unary(method, req).await; Ok(res) @@ -774,13 +830,17 @@ pub mod outbound_policies_server { &mut self, request: tonic::Request, ) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).watch(request).await }; + let inner = Arc::clone(&self.0); + let fut = async move { + ::watch(&inner, request).await + }; Box::pin(fut) } } let accept_compression_encodings = self.accept_compression_encodings; let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; let inner = self.inner.clone(); let fut = async move { let inner = inner.0; @@ -790,6 +850,10 @@ pub mod outbound_policies_server { .apply_compression_config( accept_compression_encodings, send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, ); let res = grpc.server_streaming(method, req).await; Ok(res) @@ -818,12 +882,14 @@ pub mod outbound_policies_server { inner, accept_compression_encodings: self.accept_compression_encodings, send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, } } } impl Clone for _Inner { fn clone(&self) -> Self { - Self(self.0.clone()) + Self(Arc::clone(&self.0)) } } impl std::fmt::Debug for _Inner { diff --git a/src/gen/io.linkerd.proxy.tap.rs b/src/gen/io.linkerd.proxy.tap.rs index a106a7f0f..3e40715d4 100644 --- a/src/gen/io.linkerd.proxy.tap.rs +++ b/src/gen/io.linkerd.proxy.tap.rs @@ -410,10 +410,26 @@ pub mod tap_client { self.inner = self.inner.accept_compressed(encoding); self } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_decoding_message_size(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.inner = self.inner.max_encoding_message_size(limit); + self + } pub async fn observe( &mut self, request: impl tonic::IntoRequest, - ) -> Result< + ) -> std::result::Result< tonic::Response>, tonic::Status, > { @@ -430,7 +446,10 @@ pub mod tap_client { let path = http::uri::PathAndQuery::from_static( "/io.linkerd.proxy.tap.Tap/Observe", ); - self.inner.server_streaming(request.into_request(), path, codec).await + let mut req = request.into_request(); + req.extensions_mut() + .insert(GrpcMethod::new("io.linkerd.proxy.tap.Tap", "Observe")); + self.inner.server_streaming(req, path, codec).await } } } @@ -442,15 +461,15 @@ pub mod tap_server { #[async_trait] pub trait Tap: Send + Sync + 'static { /// Server streaming response type for the Observe method. - type ObserveStream: futures_core::Stream< - Item = Result, + type ObserveStream: tonic::codegen::tokio_stream::Stream< + Item = std::result::Result, > + Send + 'static; async fn observe( &self, request: tonic::Request, - ) -> Result, tonic::Status>; + ) -> std::result::Result, tonic::Status>; } /// A service exposed by proxy instances to setup #[derive(Debug)] @@ -458,6 +477,8 @@ pub mod tap_server { inner: _Inner, accept_compression_encodings: EnabledCompressionEncodings, send_compression_encodings: EnabledCompressionEncodings, + max_decoding_message_size: Option, + max_encoding_message_size: Option, } struct _Inner(Arc); impl TapServer { @@ -470,6 +491,8 @@ pub mod tap_server { inner, accept_compression_encodings: Default::default(), send_compression_encodings: Default::default(), + max_decoding_message_size: None, + max_encoding_message_size: None, } } pub fn with_interceptor( @@ -493,6 +516,22 @@ pub mod tap_server { self.send_compression_encodings.enable(encoding); self } + /// Limits the maximum size of a decoded message. + /// + /// Default: `4MB` + #[must_use] + pub fn max_decoding_message_size(mut self, limit: usize) -> Self { + self.max_decoding_message_size = Some(limit); + self + } + /// Limits the maximum size of an encoded message. + /// + /// Default: `usize::MAX` + #[must_use] + pub fn max_encoding_message_size(mut self, limit: usize) -> Self { + self.max_encoding_message_size = Some(limit); + self + } } impl tonic::codegen::Service> for TapServer where @@ -506,7 +545,7 @@ pub mod tap_server { fn poll_ready( &mut self, _cx: &mut Context<'_>, - ) -> Poll> { + ) -> Poll> { Poll::Ready(Ok(())) } fn call(&mut self, req: http::Request) -> Self::Future { @@ -529,13 +568,17 @@ pub mod tap_server { &mut self, request: tonic::Request, ) -> Self::Future { - let inner = self.0.clone(); - let fut = async move { (*inner).observe(request).await }; + let inner = Arc::clone(&self.0); + let fut = async move { + ::observe(&inner, request).await + }; Box::pin(fut) } } let accept_compression_encodings = self.accept_compression_encodings; let send_compression_encodings = self.send_compression_encodings; + let max_decoding_message_size = self.max_decoding_message_size; + let max_encoding_message_size = self.max_encoding_message_size; let inner = self.inner.clone(); let fut = async move { let inner = inner.0; @@ -545,6 +588,10 @@ pub mod tap_server { .apply_compression_config( accept_compression_encodings, send_compression_encodings, + ) + .apply_max_message_size_config( + max_decoding_message_size, + max_encoding_message_size, ); let res = grpc.server_streaming(method, req).await; Ok(res) @@ -573,12 +620,14 @@ pub mod tap_server { inner, accept_compression_encodings: self.accept_compression_encodings, send_compression_encodings: self.send_compression_encodings, + max_decoding_message_size: self.max_decoding_message_size, + max_encoding_message_size: self.max_encoding_message_size, } } } impl Clone for _Inner { fn clone(&self) -> Self { - Self(self.0.clone()) + Self(Arc::clone(&self.0)) } } impl std::fmt::Debug for _Inner {