From 8c71d110857631bb7a55e4bf180f9220b223eec5 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Thu, 25 Aug 2022 16:32:06 -0400 Subject: [PATCH] Fix tokio panic in legacy `rpm-ostree container-encapsulate` path Fixes: https://github.com/coreos/rpm-ostree/pull/3904/commits/60c8facfda1f79744a6a570613828772a7f93d93 We changed the method to be non-async (mostly) so it needs to run from the worker thread. There's a bit of the code which does run async using `block_on` and we can only do that from the worker thread. Closes: https://github.com/coreos/rpm-ostree/issues/3968 --- rust/src/main.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/rust/src/main.rs b/rust/src/main.rs index 99f4dd7f58..0d479484ab 100644 --- a/rust/src/main.rs +++ b/rust/src/main.rs @@ -30,20 +30,13 @@ async fn inner_async_main(args: Vec) -> Result { ); return rpmostree_rust::container::entrypoint(&args_borrowed).await; } - // This is a deprecated entrypoint - "container-encapsulate" => { - rpmostree_rust::client::warn_future_incompatibility( - "This entrypoint is deprecated; use `rpm-ostree compose container-encapsulate` instead", - ); - rpmostree_rust::container::container_encapsulate(args)?; - return Ok(0); - } _ => {} } // Everything below here is a blocking API, and run on a worker thread so // that the main thread is dedicated to the Tokio reactor. - tokio::task::spawn_blocking(move || { - let args_borrowed: Vec<_> = args.iter().map(|s| s.as_str()).collect(); + tokio::task::spawn_blocking(move || -> Result { + let args_orig = args; + let args_borrowed: Vec<_> = args_orig.iter().map(|s| s.as_str()).collect(); let args = &args_borrowed[..]; if let Some(arg) = args.get(1) { match *arg { @@ -54,6 +47,13 @@ async fn inner_async_main(args: Vec) -> Result { "usroverlay" | "unlock" => builtins::usroverlay::entrypoint(args).map(|_| 0), // A hidden wrapper to intercept some binaries in RPM scriptlets. "scriptlet-intercept" => builtins::scriptlet_intercept::entrypoint(args).map(|_| 0), + // This is a deprecated entrypoint + "container-encapsulate" => { + rpmostree_rust::client::warn_future_incompatibility( + "This entrypoint is deprecated; use `rpm-ostree compose container-encapsulate` instead", + ); + rpmostree_rust::container::container_encapsulate(args_orig).map(|_| 0) + }, // C++ main _ => Ok(rpmostree_rust::ffi::rpmostree_main(args)?), }