diff --git a/Cargo.toml b/Cargo.toml index 8733101e..c7745011 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -35,9 +35,9 @@ nix = "0.29" oci-spec = "0.6" os_pipe = "1.1" prctl = "1.0.0" -prost = "0.12" -prost-build = "0.12" -prost-types = "0.12" +prost = "0.13" +prost-build = "0.13" +prost-types = "0.13" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" simple_logger = { version = "5.0", default-features = false } @@ -45,7 +45,7 @@ tempfile = "3.6" thiserror = "1.0" time = { version = "0.3.29", features = ["serde", "std", "formatting"] } tokio = "1.26" -tonic = "0.11" -tonic-build = "0.11" +tonic = "0.12" +tonic-build = "0.12" tower = "0.4" uuid = { version = "1.0", features = ["v4"] } diff --git a/crates/client/Cargo.toml b/crates/client/Cargo.toml index 9616e08d..d89af8bf 100644 --- a/crates/client/Cargo.toml +++ b/crates/client/Cargo.toml @@ -23,6 +23,7 @@ name = "version" path = "examples/version.rs" [dependencies] +hyper-util = "0.1.6" # https://github.com/hyperium/hyper/issues/3110 prost.workspace = true prost-types.workspace = true tokio = { workspace = true, optional = true } diff --git a/crates/client/build.rs b/crates/client/build.rs index 941bee0d..2c52cb20 100644 --- a/crates/client/build.rs +++ b/crates/client/build.rs @@ -70,7 +70,7 @@ fn main() { tonic_build::configure() .build_server(false) - .compile_with_config(config, PROTO_FILES, &["vendor/"]) + .compile_protos_with_config(config, PROTO_FILES, &["vendor/"]) .expect("Failed to generate GRPC bindings"); for module in FIXUP_MODULES { diff --git a/crates/client/src/lib.rs b/crates/client/src/lib.rs index 74dd798d..89f3a80e 100644 --- a/crates/client/src/lib.rs +++ b/crates/client/src/lib.rs @@ -86,23 +86,29 @@ pub async fn connect( let path = path.as_ref().to_path_buf(); - // Taken from https://github.com/hyperium/tonic/blob/eeb3268f71ae5d1107c937392389db63d8f721fb/examples/src/uds/client.rs#L19 + // Taken from https://github.com/hyperium/tonic/blob/71fca362d7ffbb230547f23b3f2fb75c414063a8/examples/src/uds/client.rs#L21-L28 // There will ignore this uri because uds do not use it // and make connection with UnixStream::connect. - let channel = Endpoint::try_from("http://[::]") - .unwrap() + let channel = Endpoint::try_from("http://[::]")? .connect_with_connector(tower::service_fn(move |_| { - #[cfg(unix)] - { - tokio::net::UnixStream::connect(path.clone()) - } - - #[cfg(windows)] - { - let client = tokio::net::windows::named_pipe::ClientOptions::new() - .open(path.clone()) - .map_err(|e| std::io::Error::from(e)); - async move { client } + let path = path.clone(); + + async move { + #[cfg(unix)] + { + Ok::<_, std::io::Error>(hyper_util::rt::TokioIo::new( + tokio::net::UnixStream::connect(path).await?, + )) + } + + #[cfg(windows)] + { + let client = tokio::net::windows::named_pipe::ClientOptions::new() + .open(&path) + .map_err(|e| std::io::Error::from(e))?; + + Ok::<_, std::io::Error>(hyper_util::rt::TokioIo::new(client)) + } } })) .await?; diff --git a/crates/runc/src/utils.rs b/crates/runc/src/utils.rs index 750a116a..15596fe0 100644 --- a/crates/runc/src/utils.rs +++ b/crates/runc/src/utils.rs @@ -98,6 +98,7 @@ pub async fn write_value_to_temp_file(value: &T) -> Result>(args: &[S]) -> Result { }) .map_err(|e| Error::InvalidArgument(e.to_string()))?; - if let Some(action) = args.get(0) { + if let Some(action) = args.first() { flags.action = action.into(); } diff --git a/crates/shim/src/lib.rs b/crates/shim/src/lib.rs index 5f447bd7..d428fd82 100644 --- a/crates/shim/src/lib.rs +++ b/crates/shim/src/lib.rs @@ -94,14 +94,12 @@ macro_rules! cfg_async { } cfg_not_async! { - pub use crate::synchronous::*; pub use crate::synchronous::publisher; pub use protos::shim::shim_ttrpc::Task; pub use protos::ttrpc::TtrpcContext; } cfg_async! { - pub use crate::asynchronous::*; pub use crate::asynchronous::publisher; pub use protos::shim_async::Task; pub use protos::ttrpc::r#async::TtrpcContext; diff --git a/crates/shim/src/sys/mod.rs b/crates/shim/src/sys/mod.rs index 3f98c21e..6972b767 100644 --- a/crates/shim/src/sys/mod.rs +++ b/crates/shim/src/sys/mod.rs @@ -17,4 +17,5 @@ #[cfg(windows)] pub(crate) mod windows; #[cfg(windows)] +#[allow(unused_imports)] pub use crate::sys::windows::NamedPipeLogger; diff --git a/crates/shim/src/sys/windows/named_pipe_logger.rs b/crates/shim/src/sys/windows/named_pipe_logger.rs index 1121c5f1..01830984 100644 --- a/crates/shim/src/sys/windows/named_pipe_logger.rs +++ b/crates/shim/src/sys/windows/named_pipe_logger.rs @@ -100,7 +100,7 @@ impl log::Log for NamedPipeLogger { .current_connection .lock() .unwrap() - .write(message.as_bytes()) + .write_all(message.as_bytes()) { Ok(_) => {} Err(ref e) if e.kind() == io::ErrorKind::Interrupted => { diff --git a/crates/snapshots/build.rs b/crates/snapshots/build.rs index c6785fa7..862f2206 100644 --- a/crates/snapshots/build.rs +++ b/crates/snapshots/build.rs @@ -26,7 +26,7 @@ const FIXUP_MODULES: &[&str] = &["containerd.services.snapshots.v1"]; fn main() { tonic_build::configure() .build_server(true) - .compile(PROTO_FILES, &["vendor/"]) + .compile_protos(PROTO_FILES, &["vendor/"]) .expect("Failed to generate GRPC bindings"); for module in FIXUP_MODULES { diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 23dbc5c8..db3e0d02 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.74" +channel = "1.77" components = ["rustfmt", "clippy", "llvm-tools"]