Skip to content

Commit

Permalink
Merge pull request #2075 from bitoku/bump-capnp
Browse files Browse the repository at this point in the history
Bump capnp to 0.19.2
  • Loading branch information
openshift-merge-bot[bot] authored Mar 20, 2024
2 parents 4351327 + 1df4925 commit 526bab4
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 44 deletions.
25 changes: 17 additions & 8 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions conmon-rs/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion conmon-rs/client/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {

println!(
"received: {}",
response.get()?.get_response()?.get_version()?
response.get()?.get_response()?.get_version()?.to_str()?
);
Ok(())
})
Expand Down
6 changes: 3 additions & 3 deletions conmon-rs/common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
4 changes: 2 additions & 2 deletions conmon-rs/server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
5 changes: 4 additions & 1 deletion conmon-rs/server/src/capnp_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
))
}
}

Expand Down
4 changes: 2 additions & 2 deletions conmon-rs/server/src/container_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
46 changes: 25 additions & 21 deletions conmon-rs/server/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Result<Vec<_>, _>>())
};
}

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::<Result<Vec<_>, _>>())
};
}

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::<Result<Vec<_>, _>>())
};
}

Expand Down Expand Up @@ -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<String> = pry!(pry!(req.get_cleanup_cmd())
.iter()
.map(|s| s.map(String::from))
.collect());
let cleanup_cmd: Vec<String> = capnp_vec_str!(req.get_cleanup_cmd());

debug!("Got a create container request");

Expand All @@ -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());

Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -303,20 +307,20 @@ 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();
pry_err!(Telemetry::set_parent_context(pry!(req.get_metadata())));

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();

Expand All @@ -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();
Expand All @@ -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();
Expand All @@ -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()));
Expand All @@ -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()),
Expand Down
8 changes: 4 additions & 4 deletions conmon-rs/server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ impl Server {
info!("Received SIGINT");
handled_sig = Signal::SIGINT;
}
};
}

if let Some(pause) = Pause::maybe_shared() {
pause.stop();
Expand Down Expand Up @@ -330,7 +330,7 @@ impl GenerateRuntimeArgs<'_> {
}

for arg in global_args {
args.push(arg?.to_string());
args.push(arg?.to_string()?);
}

args.extend([
Expand All @@ -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() {
Expand Down Expand Up @@ -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(" "));
Expand Down

0 comments on commit 526bab4

Please sign in to comment.