Skip to content

Commit

Permalink
Merge pull request #142 from Mossaka/wasmtime-youki
Browse files Browse the repository at this point in the history
Use youki's libcontainer APIs to implement wasmtime shim.
  • Loading branch information
cpuguy83 authored Jul 10, 2023
2 parents c0480e9 + dfc680d commit 0a5a758
Show file tree
Hide file tree
Showing 16 changed files with 622 additions and 604 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,19 @@ jobs:
- uses: actions/checkout@v3
- name: setup rust-wasm target
run: rustup target add wasm32-wasi
- name: Setup OCI runtime build env
run: |
sudo apt -y update
sudo apt install -y pkg-config libsystemd-dev libdbus-glib-1-dev build-essential libelf-dev libseccomp-dev libclang-dev
- name: run
run: make test/k8s
run: |
make test/k8s
# only runs when the previous step fails
- name: inspect failed pods
if: failure()
run: |
kubectl get pods --all-namespaces
kubectl describe pods --all-namespaces
- name: cleanup
if: always()
run: make test/k8s/clean
Expand Down
174 changes: 3 additions & 171 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ members = [
"crates/oci-tar-builder",
"crates/containerd-shim-wasmedge",
"crates/containerd-shim-wasmtime",
"benches/containerd-shim-benchmarks",
]

[workspace.package]
Expand All @@ -18,6 +17,7 @@ homepage = "https://github.com/containerd/runwasi"

[workspace.dependencies]
anyhow = "1.0"
containerd-shim-wasm = { path = "crates/containerd-shim-wasm" }
serde = "1.0"
serde_json = "1.0"
env_logger = "0.10"
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ fix:

.PHONY: test
test:
cargo test --all --verbose
RUST_LOG=trace cargo test --all --verbose -- --nocapture

.PHONY: install
install:
Expand Down
2 changes: 1 addition & 1 deletion crates/containerd-shim-wasm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ rand = "0.8"
[features]
default = []
generate_bindings = ["ttrpc-codegen"]
generate_doc = []
generate_doc = []
10 changes: 8 additions & 2 deletions crates/containerd-shim-wasm/src/sandbox/instance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub struct InstanceConfig<E>
where
E: Send + Sync + Clone,
{
/// The wasm engine to use.
/// The WASI engine to use.
/// This should be cheap to clone.
engine: E,
/// Optional stdin named pipe path.
Expand Down Expand Up @@ -104,21 +104,27 @@ where
}
}

/// Represents a wasi module(s).
/// Represents a WASI module(s).
/// Instance is a trait that gets implemented by consumers of this library.
pub trait Instance {
/// The WASI engine type
type E: Send + Sync + Clone;

/// Create a new instance
fn new(id: String, cfg: Option<&InstanceConfig<Self::E>>) -> Self;

/// Start the instance
/// The returned value should be a unique ID (such as a PID) for the instance.
/// Nothing internally should be using this ID, but it is returned to containerd where a user may want to use it.
fn start(&self) -> Result<u32, Error>;

/// Send a signal to the instance
fn kill(&self, signal: u32) -> Result<(), Error>;

/// Delete any reference to the instance
/// This is called after the instance has exited.
fn delete(&self) -> Result<(), Error>;

/// Set up waiting for the instance to exit
/// The Wait struct is used to send the exit code and time back to the
/// caller. The recipient is expected to call function
Expand Down
Loading

0 comments on commit 0a5a758

Please sign in to comment.