From 1df4925a13edb86585c4d0284bc32e968f4d490d Mon Sep 17 00:00:00 2001 From: Ayato Tokubi Date: Wed, 20 Mar 2024 00:42:07 +0000 Subject: [PATCH] Bump capnp to 0.19.2 Signed-off-by: Ayato Tokubi --- Cargo.lock | 25 ++++++++++----- conmon-rs/client/Cargo.toml | 4 +-- conmon-rs/client/src/main.rs | 2 +- conmon-rs/common/Cargo.toml | 6 ++-- conmon-rs/server/Cargo.toml | 4 +-- conmon-rs/server/src/capnp_util.rs | 5 ++- conmon-rs/server/src/container_log.rs | 4 +-- conmon-rs/server/src/rpc.rs | 46 +++++++++++++++------------ conmon-rs/server/src/server.rs | 8 ++--- 9 files changed, 60 insertions(+), 44 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 368bd651e4..31d068ea86 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -230,15 +230,18 @@ checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223" [[package]] name = "capnp" -version = "0.17.2" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95e65021d89250bbfe7c2791789ced2c4bdc21b0e8bb59c64f3fd6145a5fd678" +checksum = "b4bfb7088540597aa9a835f445dae750aa0792f84d253c6cd515940486e98e00" +dependencies = [ + "embedded-io", +] [[package]] name = "capnp-futures" -version = "0.17.1" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a600667bb198b5d34e9cd90d23b88c0a2a2c36d5f3edc9e6aafc7d5a206bc750" +checksum = "5fac483cb34e3bc0be251dba7ce318f465143dd18f948c7bd7ad035f6fecfb1b" dependencies = [ "capnp", "futures", @@ -246,9 +249,9 @@ dependencies = [ [[package]] name = "capnp-rpc" -version = "0.17.0" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9ab8e869783e491cbcc350427a5e775aa4d8a1deaa5198d74332957cfa430779" +checksum = "171dba986cf6aaa4a2a86f1a2fb7372f456d3cb95f2cb27f4dc45ae9ea850a16" dependencies = [ "capnp", "capnp-futures", @@ -257,9 +260,9 @@ dependencies = [ [[package]] name = "capnpc" -version = "0.17.2" +version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fbbc3763fb3e6635188e9cc51ee11a26f8777c553ca377430818dbebaaf6042b" +checksum = "c75ba30e0f08582d53c2f3710cf4bb65ff562614b1ba86906d7391adffe189ec" dependencies = [ "capnp", ] @@ -529,6 +532,12 @@ version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" +[[package]] +name = "embedded-io" +version = "0.6.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d" + [[package]] name = "equivalent" version = "1.0.1" diff --git a/conmon-rs/client/Cargo.toml b/conmon-rs/client/Cargo.toml index 4896a316fd..79ab86dd89 100644 --- a/conmon-rs/client/Cargo.toml +++ b/conmon-rs/client/Cargo.toml @@ -4,8 +4,8 @@ version = "0.6.1" edition = "2021" [dependencies] -capnp = "0.17.2" -capnp-rpc = "0.17.0" +capnp = "0.19.2" +capnp-rpc = "0.19.0" conmon-common = { path = "../common" } futures = "0.3.30" log = { version = "0.4.21", features = ["serde", "std"] } diff --git a/conmon-rs/client/src/main.rs b/conmon-rs/client/src/main.rs index 2f8563180d..8aef70a170 100644 --- a/conmon-rs/client/src/main.rs +++ b/conmon-rs/client/src/main.rs @@ -28,7 +28,7 @@ async fn main() -> Result<(), Box> { println!( "received: {}", - response.get()?.get_response()?.get_version()? + response.get()?.get_response()?.get_version()?.to_str()? ); Ok(()) }) diff --git a/conmon-rs/common/Cargo.toml b/conmon-rs/common/Cargo.toml index b4b3fb520a..f710d15244 100644 --- a/conmon-rs/common/Cargo.toml +++ b/conmon-rs/common/Cargo.toml @@ -5,8 +5,8 @@ version = "0.6.1" edition = "2021" [dependencies] -capnp = "0.17.2" +capnp = "0.19.2" [build-dependencies] -capnp = "0.17.2" -capnpc = "0.17.2" +capnp = "0.19.2" +capnpc = "0.19.0" diff --git a/conmon-rs/server/Cargo.toml b/conmon-rs/server/Cargo.toml index 6598a25cef..960f0aafe1 100644 --- a/conmon-rs/server/Cargo.toml +++ b/conmon-rs/server/Cargo.toml @@ -9,8 +9,8 @@ path = "src/main.rs" [dependencies] anyhow = "1.0.81" -capnp = "0.17.2" -capnp-rpc = "0.17.0" +capnp = "0.19.2" +capnp-rpc = "0.19.0" clap = { version = "4.3.8", features = ["color", "cargo", "deprecated", "derive", "deprecated", "env", "string", "unicode", "wrap_help"] } command-fds = { version = "0.3.0", features = ["tokio"] } conmon-common = { path = "../common" } diff --git a/conmon-rs/server/src/capnp_util.rs b/conmon-rs/server/src/capnp_util.rs index f5cc04f33d..37008ab401 100644 --- a/conmon-rs/server/src/capnp_util.rs +++ b/conmon-rs/server/src/capnp_util.rs @@ -27,7 +27,10 @@ mod map_entry { V: From<&'a str>, { fn into_key_value(entry: Self::Reader<'a>) -> capnp::Result<(K, V)> { - Ok((entry.get_key()?.into(), entry.get_value()?.into())) + Ok(( + entry.get_key()?.to_str()?.into(), + entry.get_value()?.to_str()?.into(), + )) } } diff --git a/conmon-rs/server/src/container_log.rs b/conmon-rs/server/src/container_log.rs index 5f287358ba..5fb8a8e349 100644 --- a/conmon-rs/server/src/container_log.rs +++ b/conmon-rs/server/src/container_log.rs @@ -32,7 +32,7 @@ impl ContainerLog { match x.get_type()? { Type::ContainerRuntimeInterface => { Ok(LogDriver::ContainerRuntimeInterface(CriLogger::new( - x.get_path()?, + x.get_path()?.to_str()?, if x.get_max_size() > 0 { Some(x.get_max_size() as usize) } else { @@ -41,7 +41,7 @@ impl ContainerLog { )?)) } Type::Json => Ok(LogDriver::Json(JsonLogger::new( - x.get_path()?, + x.get_path()?.to_str()?, if x.get_max_size() > 0 { Some(x.get_max_size() as usize) } else { diff --git a/conmon-rs/server/src/rpc.rs b/conmon-rs/server/src/rpc.rs index 8dae7cfc97..6acc98aa62 100644 --- a/conmon-rs/server/src/rpc.rs +++ b/conmon-rs/server/src/rpc.rs @@ -43,21 +43,28 @@ macro_rules! new_root_span { }; } -macro_rules! capnp_vec_str { +/// capnp_text_list takes text_list as an input and outputs list of text. +macro_rules! capnp_text_list { ($x:expr) => { - capnp_vec!($x, String::from) + pry!(pry!($x).iter().collect::, _>>()) }; } -macro_rules! capnp_vec_path { +macro_rules! capnp_vec_str { ($x:expr) => { - capnp_vec!($x, PathBuf::from) + pry!(capnp_text_list!($x) + .iter() + .map(|s| s.to_string()) + .collect::, _>>()) }; } -macro_rules! capnp_vec { - ($x:expr, $from:expr) => { - pry!(pry!($x).iter().map(|r| r.map($from)).collect()) +macro_rules! capnp_vec_path { + ($x:expr) => { + pry!(capnp_text_list!($x) + .iter() + .map(|s| s.to_str().map(|x| PathBuf::from(x))) + .collect::, _>>()) }; } @@ -97,16 +104,13 @@ impl conmon::Server for Server { mut results: conmon::CreateContainerResults, ) -> Promise<(), capnp::Error> { let req = pry!(pry!(params.get()).get_request()); - let id = pry!(req.get_id()).to_string(); + let id = pry!(pry!(req.get_id()).to_string()); let span = new_root_span!("create_container", id.as_str()); let _enter = span.enter(); pry_err!(Telemetry::set_parent_context(pry!(req.get_metadata()))); - let cleanup_cmd: Vec = pry!(pry!(req.get_cleanup_cmd()) - .iter() - .map(|s| s.map(String::from)) - .collect()); + let cleanup_cmd: Vec = capnp_vec_str!(req.get_cleanup_cmd()); debug!("Got a create container request"); @@ -115,7 +119,7 @@ impl conmon::Server for Server { let mut container_io = pry_err!(ContainerIO::new(req.get_terminal(), container_log.clone())); - let bundle_path = Path::new(pry!(req.get_bundle_path())); + let bundle_path = Path::new(pry!(pry!(req.get_bundle_path()).to_str())); let pidfile = bundle_path.join("pidfile"); debug!("PID file is {}", pidfile.display()); @@ -201,7 +205,7 @@ impl conmon::Server for Server { mut results: conmon::ExecSyncContainerResults, ) -> Promise<(), capnp::Error> { let req = pry!(pry!(params.get()).get_request()); - let id = pry!(req.get_id()).to_string(); + let id = pry!(pry!(req.get_id()).to_string()); let span = new_root_span!("exec_sync_container", id.as_str()); let _enter = span.enter(); @@ -303,7 +307,7 @@ impl conmon::Server for Server { _: conmon::AttachContainerResults, ) -> Promise<(), capnp::Error> { let req = pry!(pry!(params.get()).get_request()); - let id = pry_err!(req.get_id()); + let id = pry_err!(pry_err!(req.get_id()).to_str()); let span = new_root_span!("attach_container", id); let _enter = span.enter(); @@ -311,12 +315,12 @@ impl conmon::Server for Server { debug!("Got a attach container request",); - let exec_session_id = pry_err!(req.get_exec_session_id()); + let exec_session_id = pry_err!(pry_err!(req.get_exec_session_id()).to_str()); if !exec_session_id.is_empty() { debug!("Using exec session id {}", exec_session_id); } - let socket_path = pry!(req.get_socket_path()).to_string(); + let socket_path = pry!(pry!(req.get_socket_path()).to_string()); let child = pry_err!(self.reaper().get(id)); let stop_after_stdin_eof = req.get_stop_after_stdin_eof(); @@ -342,7 +346,7 @@ impl conmon::Server for Server { _: conmon::ReopenLogContainerResults, ) -> Promise<(), capnp::Error> { let req = pry!(pry!(params.get()).get_request()); - let id = pry_err!(req.get_id()); + let id = pry_err!(pry_err!(req.get_id()).to_str()); let span = new_root_span!("reopen_log_container", id); let _enter = span.enter(); @@ -365,7 +369,7 @@ impl conmon::Server for Server { _: conmon::SetWindowSizeContainerResults, ) -> Promise<(), capnp::Error> { let req = pry!(pry!(params.get()).get_request()); - let id = pry_err!(req.get_id()); + let id = pry_err!(pry_err!(req.get_id()).to_str()); let span = new_root_span!("set_window_size_container", id); let _enter = span.enter(); @@ -391,7 +395,7 @@ impl conmon::Server for Server { ) -> Promise<(), capnp::Error> { debug!("Got a create namespaces request"); let req = pry!(pry!(params.get()).get_request()); - let pod_id = pry_err!(req.get_pod_id()); + let pod_id = pry_err!(pry_err!(req.get_pod_id()).to_str()); if pod_id.is_empty() { return Promise::err(Error::failed("no pod ID provided".into())); @@ -402,7 +406,7 @@ impl conmon::Server for Server { pry_err!(Telemetry::set_parent_context(pry!(req.get_metadata()))); let pause = pry_err!(Pause::init_shared( - pry!(req.get_base_path()), + pry!(pry!(req.get_base_path()).to_str()), pod_id, pry!(req.get_namespaces()), capnp_vec_str!(req.get_uid_mappings()), diff --git a/conmon-rs/server/src/server.rs b/conmon-rs/server/src/server.rs index cff5d27de4..3d0a0adbff 100644 --- a/conmon-rs/server/src/server.rs +++ b/conmon-rs/server/src/server.rs @@ -239,7 +239,7 @@ impl Server { info!("Received SIGINT"); handled_sig = Signal::SIGINT; } - }; + } if let Some(pause) = Pause::maybe_shared() { pause.stop(); @@ -330,7 +330,7 @@ impl GenerateRuntimeArgs<'_> { } for arg in global_args { - args.push(arg?.to_string()); + args.push(arg?.to_string()?); } args.extend([ @@ -342,7 +342,7 @@ impl GenerateRuntimeArgs<'_> { ]); for arg in command_args { - args.push(arg?.to_string()); + args.push(arg?.to_string()?); } if let ContainerIOType::Terminal(terminal) = self.container_io.typ() { @@ -379,7 +379,7 @@ impl GenerateRuntimeArgs<'_> { args.push(self.id.into()); for arg in command { - args.push(arg?.to_string()); + args.push(arg?.to_string()?); } debug!("Exec args {:?}", args.join(" "));