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: Update tonic and prost dependencies to latest #307

Merged
merged 9 commits into from
Oct 5, 2024
10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,17 @@ 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 }
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"] }
1 change: 1 addition & 0 deletions crates/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion crates/client/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
34 changes: 20 additions & 14 deletions crates/client/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
bryantbiggs marked this conversation as resolved.
Show resolved Hide resolved
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?;
Expand Down
1 change: 1 addition & 0 deletions crates/runc/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ pub async fn write_value_to_temp_file<T: Serialize>(value: &T) -> Result<String,
let filename = format!("{}/runc-process-{}", xdg_runtime_dir(), Uuid::new_v4());
let mut f = tokio::fs::OpenOptions::new()
.create(true)
.truncate(true)
.write(true)
.open(&filename)
.await
Expand Down
2 changes: 1 addition & 1 deletion crates/shim/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ pub fn parse<S: AsRef<OsStr>>(args: &[S]) -> Result<Flags> {
})
.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();
}

Expand Down
2 changes: 0 additions & 2 deletions crates/shim/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions crates/shim/src/sys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@
#[cfg(windows)]
pub(crate) mod windows;
#[cfg(windows)]
#[allow(unused_imports)]
pub use crate::sys::windows::NamedPipeLogger;
2 changes: 1 addition & 1 deletion crates/shim/src/sys/windows/named_pipe_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down
2 changes: 1 addition & 1 deletion crates/snapshots/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.74"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

min version that resolved this error:

error: unsupported output in build script of `containerd-client v0.5.0 (/Users/runner/work/rust-extensions/rust-extensions/crates/client)`: `cargo::rerun-if-changed=vendor/github.com/containerd/containerd/api/types/descriptor.proto`
Found a `cargo::key=value` build directive which is reserved for future use.
Either change the directive to `cargo:key=value` syntax (note the single `:`) or upgrade your version of Rust.
See https://doc.rust-lang.org/cargo/reference/build-scripts.html#outputs-of-the-build-script for more information about build script outputs.
warning: build failed, waiting for other jobs to finish...

channel = "1.77"
components = ["rustfmt", "clippy", "llvm-tools"]
Loading