From 8ddac761c312642297dd5f76f1e2a0d6f46fd7cc Mon Sep 17 00:00:00 2001 From: Rajat Jindal Date: Sun, 17 Mar 2024 08:42:08 +0530 Subject: [PATCH 1/2] add workload delete test Signed-off-by: Rajat Jindal --- Makefile | 6 +++++- scripts/workloads-delete.sh | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100755 scripts/workloads-delete.sh diff --git a/Makefile b/Makefile index b930cf4..26f71d0 100644 --- a/Makefile +++ b/Makefile @@ -43,8 +43,12 @@ pod-status-check: workloads: ./scripts/workloads.sh +./PHONY: test-workloads-delete +test-workloads-delete: + ./scripts/workloads-delete.sh + .PHONY: integration-tests -integration-tests: check-bins move-bins up pod-status-check workloads +integration-tests: check-bins move-bins up pod-status-check workloads test-workloads-delete cargo test -p containerd-shim-spin-tests -- --nocapture .PHONY: tests/clean diff --git a/scripts/workloads-delete.sh b/scripts/workloads-delete.sh new file mode 100755 index 0000000..8024edf --- /dev/null +++ b/scripts/workloads-delete.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -euo pipefail + +## test that the workload pods can be terminated +kubectl delete pod -l app=wasm-spin --timeout 10s +kubectl delete pod -l app=spin-keyvalue --timeout 10s +kubectl delete pod -l app=spin-outbound-redis --timeout 10s + From f1d7e6fbfa6b087e6e9a913a127662e3dcf4b3fd Mon Sep 17 00:00:00 2001 From: Rajat Jindal Date: Tue, 26 Mar 2024 07:49:14 +0530 Subject: [PATCH 2/2] move signal handler to run_wasi Signed-off-by: Rajat Jindal --- containerd-shim-spin/src/engine.rs | 37 +++++++++++++++--------------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/containerd-shim-spin/src/engine.rs b/containerd-shim-spin/src/engine.rs index 599466f..260851d 100644 --- a/containerd-shim-spin/src/engine.rs +++ b/containerd-shim-spin/src/engine.rs @@ -232,22 +232,7 @@ impl SpinEngine { } }; info!(" >>> notifying main thread we are about to start"); - let (abortable, abort_handle) = futures::future::abortable(f); - ctrlc::set_handler(move || abort_handle.abort())?; - match abortable.await { - Ok(Ok(())) => { - info!("Trigger executor shut down: exiting"); - Ok(()) - } - Ok(Err(err)) => { - log::error!("ERROR >>> Trigger executor failed: {:?}", err); - Err(err) - } - Err(aborted) => { - info!("Received signal to abort: {:?}", aborted); - Ok(()) - } - } + f.await } async fn load_resolved_app_source( @@ -339,8 +324,24 @@ impl Engine for SpinEngine { stdio.redirect()?; info!("setting up wasi"); let rt = Runtime::new().context("failed to create runtime")?; - rt.block_on(self.wasm_exec_async(ctx))?; - Ok(0) + + let (abortable, abort_handle) = futures::future::abortable(self.wasm_exec_async(ctx)); + ctrlc::set_handler(move || abort_handle.abort())?; + + match rt.block_on(abortable) { + Ok(Ok(())) => { + info!("run_wasi shut down: exiting"); + Ok(0) + } + Ok(Err(err)) => { + log::error!("run_wasi ERROR >>> failed: {:?}", err); + Err(err) + } + Err(aborted) => { + info!("Received signal to abort: {:?}", aborted); + Ok(0) + } + } } fn can_handle(&self, _ctx: &impl RuntimeContext) -> Result<()> {