From 62972adf24e6d34a45a08e56bfe01d9797231615 Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Tue, 15 Aug 2023 22:42:12 +0000 Subject: [PATCH 1/2] Follow up to #219 and #156 Signed-off-by: James Sturtevant --- crates/containerd-shim-wasmedge/src/executor.rs | 15 ++++++--------- crates/containerd-shim-wasmtime/src/executor.rs | 15 ++++++--------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/crates/containerd-shim-wasmedge/src/executor.rs b/crates/containerd-shim-wasmedge/src/executor.rs index 0660cb11f..7cf591ec1 100644 --- a/crates/containerd-shim-wasmedge/src/executor.rs +++ b/crates/containerd-shim-wasmedge/src/executor.rs @@ -55,15 +55,12 @@ impl Executor for WasmEdgeExecutor { fn can_handle(&self, spec: &Spec) -> bool { // check if the entrypoint of the spec is a wasm binary. - let args = oci::get_args(spec); - if args.is_empty() { - return false; - } - - let start = args[0].clone(); - let mut iterator = start.split('#'); - let cmd = iterator.next().unwrap().to_string(); - let path = PathBuf::from(cmd); + let (module_name, _method) = oci::get_module(spec); + let module_name = match module_name { + Some(m) => m, + None => return false, + }; + let path = PathBuf::from(module_name); path.extension() .map(|ext| ext.to_ascii_lowercase()) diff --git a/crates/containerd-shim-wasmtime/src/executor.rs b/crates/containerd-shim-wasmtime/src/executor.rs index 1f935afb0..da0079764 100644 --- a/crates/containerd-shim-wasmtime/src/executor.rs +++ b/crates/containerd-shim-wasmtime/src/executor.rs @@ -57,15 +57,12 @@ impl Executor for WasmtimeExecutor { fn can_handle(&self, spec: &Spec) -> bool { // check if the entrypoint of the spec is a wasm binary. - let args = oci::get_args(spec); - if args.is_empty() { - return false; - } - - let start = args[0].clone(); - let mut iterator = start.split('#'); - let cmd = iterator.next().unwrap().to_string(); - let path = PathBuf::from(cmd); + let (module_name, _method) = oci::get_module(spec); + let module_name = match module_name { + Some(m) => m, + None => return false, + }; + let path = PathBuf::from(module_name); // TODO: do we need to validate the wasm binary? // ```rust From 0bf5eb17a6eb25c42f85814df5ed698ce5e6906b Mon Sep 17 00:00:00 2001 From: James Sturtevant Date: Wed, 16 Aug 2023 18:07:09 +0000 Subject: [PATCH 2/2] Add log statement Signed-off-by: James Sturtevant --- crates/containerd-shim-wasmedge/src/executor.rs | 5 ++++- crates/containerd-shim-wasmtime/src/executor.rs | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/containerd-shim-wasmedge/src/executor.rs b/crates/containerd-shim-wasmedge/src/executor.rs index 7cf591ec1..4612a4313 100644 --- a/crates/containerd-shim-wasmedge/src/executor.rs +++ b/crates/containerd-shim-wasmedge/src/executor.rs @@ -58,7 +58,10 @@ impl Executor for WasmEdgeExecutor { let (module_name, _method) = oci::get_module(spec); let module_name = match module_name { Some(m) => m, - None => return false, + None => { + log::info!("WasmEdge cannot handle this workload, no arguments provided"); + return false; + } }; let path = PathBuf::from(module_name); diff --git a/crates/containerd-shim-wasmtime/src/executor.rs b/crates/containerd-shim-wasmtime/src/executor.rs index da0079764..ab7b938bc 100644 --- a/crates/containerd-shim-wasmtime/src/executor.rs +++ b/crates/containerd-shim-wasmtime/src/executor.rs @@ -60,7 +60,10 @@ impl Executor for WasmtimeExecutor { let (module_name, _method) = oci::get_module(spec); let module_name = match module_name { Some(m) => m, - None => return false, + None => { + log::info!("Wasmtime cannot handle this workload, no arguments provided"); + return false; + } }; let path = PathBuf::from(module_name);