From 09b94d9b1ed7075b188c481a5d9366948e4deca4 Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Thu, 30 Mar 2023 21:54:40 +0800 Subject: [PATCH 1/2] Revert "wapm2pirita nests all annotations under a key with the same name as the runner" This reverts commit 83bec095cf3308940ca17e892cb84219183e0b27. --- lib/wasi/src/runners/wasi.rs | 12 +++--------- lib/wasi/src/runners/wcgi/runner.rs | 25 ++++++++----------------- 2 files changed, 11 insertions(+), 26 deletions(-) diff --git a/lib/wasi/src/runners/wasi.rs b/lib/wasi/src/runners/wasi.rs index 23bff4cc87e..43ea770ab8c 100644 --- a/lib/wasi/src/runners/wasi.rs +++ b/lib/wasi/src/runners/wasi.rs @@ -151,10 +151,9 @@ impl crate::runners::Runner for WasiRunner { command: &Command, container: &WapmContainer, ) -> Result { - let Annotations { wasi } = command - .get_annotation(webc::metadata::annotations::WASI_RUNNER_URI)? - .unwrap_or_default(); - let wasi = wasi.unwrap_or_else(|| Wasi::new(command_name)); + let wasi = command + .get_annotation("wasi")? + .unwrap_or_else(|| Wasi::new(command_name)); let atom_name = &wasi.atom; let atom = container .get_atom(atom_name) @@ -169,8 +168,3 @@ impl crate::runners::Runner for WasiRunner { Ok(()) } } - -#[derive(Default, Debug, serde::Deserialize)] -struct Annotations { - wasi: Option, -} diff --git a/lib/wasi/src/runners/wcgi/runner.rs b/lib/wasi/src/runners/wcgi/runner.rs index 1b49c0d6269..83a388c8bce 100644 --- a/lib/wasi/src/runners/wcgi/runner.rs +++ b/lib/wasi/src/runners/wcgi/runner.rs @@ -41,20 +41,17 @@ impl WcgiRunner { #[tracing::instrument(skip(self, ctx))] fn run(&mut self, command_name: &str, ctx: &RunnerContext<'_>) -> Result<(), Error> { - let key = webc::metadata::annotations::WCGI_RUNNER_URI; - let Annotations { wasi, wcgi } = ctx + let wasi: Wasi = ctx .command() - .get_annotation(key) - .with_context(|| format!("Unable to deserialize the \"{key}\" annotations"))? - .unwrap_or_default(); - - let wasi = wasi.unwrap_or_else(|| Wasi::new(command_name)); + .get_annotation("wasi") + .context("Unable to retrieve the WASI metadata")? + .unwrap_or_else(|| Wasi::new(command_name)); let module = self .load_module(&wasi, ctx) .context("Couldn't load the module")?; - let handler = self.create_handler(module, &wasi, &wcgi, ctx)?; + let handler = self.create_handler(module, &wasi, ctx)?; let task_manager = Arc::clone(&handler.task_manager); let callbacks = Arc::clone(&self.config.callbacks); @@ -129,10 +126,11 @@ impl WcgiRunner { &self, module: Module, wasi: &Wasi, - wcgi: &Wcgi, ctx: &RunnerContext<'_>, ) -> Result { - let dialect = match &wcgi.dialect { + let Wcgi { dialect, .. } = ctx.command().get_annotation("wcgi")?.unwrap_or_default(); + + let dialect = match dialect { Some(d) => d.parse().context("Unable to parse the CGI dialect")?, None => CgiDialect::Wcgi, }; @@ -344,13 +342,6 @@ impl Default for Config { } } -#[derive(Debug, Default, serde::Deserialize)] -struct Annotations { - wasi: Option, - #[serde(default)] - wcgi: Wcgi, -} - /// Callbacks that are triggered at various points in the lifecycle of a runner /// and any WebAssembly instances it may start. pub trait Callbacks: Send + Sync + 'static { From 2c779dc2e23570f0ee32f304b65ebc275c1b2a9e Mon Sep 17 00:00:00 2001 From: Michael-F-Bryan Date: Thu, 30 Mar 2023 21:55:06 +0800 Subject: [PATCH 2/2] Bump to wapm-targz-to-pirita with the wasmerio/pirita#107 fix --- Cargo.lock | 4 ++-- lib/cli/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index c1e09f01c43..2165f2188b8 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4937,9 +4937,9 @@ dependencies = [ [[package]] name = "wapm-targz-to-pirita" -version = "0.1.7" +version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39980ef50ab15c47dbd9b26678f06ece2341178d82e25e21e4ac68310d1f2e63" +checksum = "6b3f2778f5f2431f74ae83607cea3ba9cd33cbfa0c75ff6caff30162668e2ed8" dependencies = [ "anyhow", "base64 0.13.1", diff --git a/lib/cli/Cargo.toml b/lib/cli/Cargo.toml index 1121715a450..7323c3c0401 100644 --- a/lib/cli/Cargo.toml +++ b/lib/cli/Cargo.toml @@ -85,7 +85,7 @@ wasm-coredump-builder = { version = "0.1.11" } tracing = { version = "0.1" } tracing-subscriber = { version = "0.3", features = [ "env-filter", "fmt" ] } clap-verbosity-flag = "1" -wapm-targz-to-pirita = "0.1.7" +wapm-targz-to-pirita = "0.1.10" [target.'cfg(not(target_arch = "riscv64"))'.dependencies] http_req = { version="^0.8", default-features = false, features = ["rust-tls"] }