From b9358088ec0eeccf2a10b43cc4cbd89292b62fce Mon Sep 17 00:00:00 2001 From: Djordje Lukic Date: Tue, 31 Jan 2023 13:47:19 +0100 Subject: [PATCH] Move call of the prestart hooks over to the lib part Moving this makes pre-start hooks work for all the instances. Signed-off-by: Djordje Lukic --- crates/containerd-shim-wasm/src/sandbox/shim.rs | 4 ++++ crates/wasmedge/src/instance.rs | 3 --- crates/wasmtime/src/instance.rs | 3 --- 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/containerd-shim-wasm/src/sandbox/shim.rs b/crates/containerd-shim-wasm/src/sandbox/shim.rs index ae856465f..b8ffac1f5 100644 --- a/crates/containerd-shim-wasm/src/sandbox/shim.rs +++ b/crates/containerd-shim-wasm/src/sandbox/shim.rs @@ -958,6 +958,10 @@ where debug!("create done"); + // Per the spec, the prestart hook must be called as part of the create operation + debug!("call prehook before the start"); + oci::setup_prestart_hooks(&spec.hooks())?; + Ok(api::CreateTaskResponse { pid: std::process::id(), ..Default::default() diff --git a/crates/wasmedge/src/instance.rs b/crates/wasmedge/src/instance.rs index 589dd10ae..ab3297ea2 100644 --- a/crates/wasmedge/src/instance.rs +++ b/crates/wasmedge/src/instance.rs @@ -194,9 +194,6 @@ impl Instance for Wasi { debug!("preparing module"); let spec = load_spec(self.bundle.clone())?; - debug!("call prehook before the start"); - oci::setup_prestart_hooks(spec.hooks())?; - let vm = prepare_module(engine, &spec, stdin, stdout, stderr) .map_err(|e| Error::Others(format!("error setting up module: {}", e)))?; diff --git a/crates/wasmtime/src/instance.rs b/crates/wasmtime/src/instance.rs index 7718d65b0..83be8a2fb 100644 --- a/crates/wasmtime/src/instance.rs +++ b/crates/wasmtime/src/instance.rs @@ -165,9 +165,6 @@ impl Instance for Wasi { debug!("preparing module"); let spec = load_spec(self.bundle.clone())?; - debug!("call prehook before the start"); - oci::setup_prestart_hooks(spec.hooks())?; - let m = prepare_module(engine.clone(), &spec, stdin, stdout, stderr) .map_err(|e| Error::Others(format!("error setting up module: {}", e)))?;