Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add workload delete test and refactor signal handling in run_wasi function #46

Merged
merged 2 commits into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
37 changes: 19 additions & 18 deletions containerd-shim-spin/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
rajatjindal marked this conversation as resolved.
Show resolved Hide resolved
}
}
}

fn can_handle(&self, _ctx: &impl RuntimeContext) -> Result<()> {
Expand Down
9 changes: 9 additions & 0 deletions scripts/workloads-delete.sh
Original file line number Diff line number Diff line change
@@ -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

Loading