diff --git a/Cargo.lock b/Cargo.lock index 55d3ac68..8c301165 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1350,7 +1350,7 @@ dependencies = [ "bitflags 2.6.0", "cexpr", "clang-sys", - "itertools 0.13.0", + "itertools 0.11.0", "proc-macro2", "quote", "regex", @@ -1933,22 +1933,13 @@ dependencies = [ "containerd-shim-wasm", "ctrlc", "futures", - "http 1.3.1", "log", "oci-spec", "openssl", - "serde", - "serde_json", "spin-app", - "spin-common", "spin-componentize", - "spin-core", - "spin-expressions", "spin-factor-outbound-networking", - "spin-factors", - "spin-factors-executor", "spin-loader", - "spin-manifest", "spin-oci", "spin-runtime-factors", "spin-telemetry", @@ -1962,31 +1953,63 @@ dependencies = [ "trigger-command", "trigger-mqtt", "trigger-sqs", - "url", "wasmtime", "wat", ] [[package]] name = "containerd-shim-wasm" -version = "0.10.0" +version = "1.0.0-rc.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16c495945a2604e3de0bbecf120e84fb783a78b709f759a9e3935e6e85b98c85" +checksum = "ae2cbd3f44b1c099a369fd46c1e67144e3aae45e5c7b9ec15315201c7fc9402e" dependencies = [ "anyhow", "caps", "chrono", "containerd-client", "containerd-shim", + "containerd-shimkit", "dbus", "futures", - "git-version", "libc", "libcontainer", "log", "mio", "nix 0.29.0", "oci-spec", + "serde", + "serde_bytes", + "serde_json", + "sha256", + "tokio", + "tokio-async-drop", + "tokio-stream", + "trait-variant", + "ttrpc-codegen", + "wasmparser 0.227.1", + "wat", + "windows-sys 0.59.0", +] + +[[package]] +name = "containerd-shimkit" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b50ce3653eadfd6a56ca25b59e8c6cbdbe4f8c215b26a3ef3af06c330c44d74a" +dependencies = [ + "anyhow", + "caps", + "chrono", + "containerd-client", + "containerd-shim", + "dbus", + "futures", + "git-version", + "libcontainer", + "log", + "mio", + "nix 0.29.0", + "oci-spec", "opentelemetry 0.23.0", "opentelemetry-otlp 0.16.0", "opentelemetry_sdk 0.23.0", @@ -1995,20 +2018,16 @@ dependencies = [ "serde", "serde_bytes", "serde_json", - "sha256", "thiserror 2.0.11", "time", "tokio", "tokio-async-drop", - "tokio-stream", "toml", "tracing", "tracing-opentelemetry 0.24.0", "tracing-subscriber", "trait-variant", "ttrpc-codegen", - "wasmparser 0.226.0", - "wat", "windows-sys 0.59.0", "zygote", ] @@ -2427,9 +2446,9 @@ dependencies = [ [[package]] name = "deranged" -version = "0.3.11" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b42b6fa04a440b495c8b04d0e71b707c585f83cb9cb28cf8cd0d976c315e31b4" +checksum = "28cfac68e08048ae1883171632c2aef3ebc555621ae56fbccce1cbf22dd7f058" dependencies = [ "powerfmt", "serde", @@ -3631,7 +3650,7 @@ dependencies = [ "http 1.3.1", "hyper 1.5.1", "hyper-util", - "rustls 0.23.20", + "rustls 0.23.25", "rustls-pki-types", "tokio", "tokio-rustls 0.26.1", @@ -4163,9 +4182,9 @@ checksum = "09edd9e8b54e49e587e4f6295a7d29c3ea94d469cb40ab8ca70b288248a81db2" [[package]] name = "libc" -version = "0.2.170" +version = "0.2.171" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "875b3680cb2f8f71bdcf9a30f38d48282f5d3c95cbf9b3fa57269bb5d5c06828" +checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6" [[package]] name = "libcgroups" @@ -5912,8 +5931,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22505a5c94da8e3b7c2996394d1c933236c4d743e81a410bcca4e6989fc066a4" dependencies = [ "bytes", - "heck 0.5.0", - "itertools 0.12.1", + "heck 0.4.1", + "itertools 0.11.0", "log", "multimap 0.10.0", "once_cell", @@ -5932,8 +5951,8 @@ version = "0.13.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0f3e5beed80eb580c68e2c600937ac2c4eedabdfd5ef1e5b7ea4f3fba84497b" dependencies = [ - "heck 0.5.0", - "itertools 0.13.0", + "heck 0.4.1", + "itertools 0.11.0", "log", "multimap 0.10.0", "once_cell", @@ -5966,7 +5985,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "81bddcdb20abf9501610992b6759a4c888aef7d1a7247ef75e2404275ac24af1" dependencies = [ "anyhow", - "itertools 0.12.1", + "itertools 0.11.0", "proc-macro2", "quote", "syn 2.0.90", @@ -5979,7 +5998,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "157c5a9d7ea5c2ed2d9fb8f495b64759f7816c7eaea54ba3978f0d63000162e3" dependencies = [ "anyhow", - "itertools 0.13.0", + "itertools 0.11.0", "proc-macro2", "quote", "syn 2.0.90", @@ -6166,7 +6185,7 @@ dependencies = [ "quinn-proto", "quinn-udp", "rustc-hash", - "rustls 0.23.20", + "rustls 0.23.25", "socket2", "thiserror 2.0.11", "tokio", @@ -6184,7 +6203,7 @@ dependencies = [ "rand 0.8.5", "ring 0.17.8", "rustc-hash", - "rustls 0.23.20", + "rustls 0.23.25", "rustls-pki-types", "slab", "thiserror 2.0.11", @@ -6576,7 +6595,7 @@ dependencies = [ "percent-encoding", "pin-project-lite", "quinn", - "rustls 0.23.20", + "rustls 0.23.25", "rustls-pemfile 2.2.0", "rustls-pki-types", "serde", @@ -6867,15 +6886,15 @@ dependencies = [ [[package]] name = "rustls" -version = "0.23.20" +version = "0.23.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5065c3f250cbd332cd894be57c40fa52387247659b14a2d6041d121547903b1b" +checksum = "822ee9188ac4ec04a2f0531e55d035fb2de73f18b41a63c70c2712503b6fb13c" dependencies = [ "log", "once_cell", "ring 0.17.8", "rustls-pki-types", - "rustls-webpki 0.102.8", + "rustls-webpki 0.103.1", "subtle", "zeroize", ] @@ -6925,9 +6944,9 @@ dependencies = [ [[package]] name = "rustls-pki-types" -version = "1.10.0" +version = "1.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "16f1201b3c9a7ee8039bcadc17b7e605e2945b27eee7631788c1bd2b0643674b" +checksum = "917ce264624a4b4db1c364dcc35bfca9ded014d0a958cd47ad3e960e988ea51c" dependencies = [ "web-time", ] @@ -6953,6 +6972,17 @@ dependencies = [ "untrusted 0.9.0", ] +[[package]] +name = "rustls-webpki" +version = "0.103.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fef8b8769aaccf73098557a87cd1816b4f9c7c16811c9c77142aa695c16f2c03" +dependencies = [ + "ring 0.17.8", + "rustls-pki-types", + "untrusted 0.9.0", +] + [[package]] name = "rustversion" version = "1.0.18" @@ -7603,7 +7633,7 @@ dependencies = [ "hyper 1.5.1", "ip_network", "reqwest 0.12.9", - "rustls 0.23.20", + "rustls 0.23.25", "spin-factor-outbound-networking", "spin-factors", "spin-telemetry", @@ -7658,7 +7688,7 @@ dependencies = [ "futures-util", "http 1.3.1", "ipnet", - "rustls 0.23.20", + "rustls 0.23.25", "rustls-pemfile 2.2.0", "rustls-pki-types", "serde", @@ -8130,7 +8160,7 @@ dependencies = [ "http-body-util", "hyper 1.5.1", "hyper-util", - "rustls 0.23.20", + "rustls 0.23.25", "rustls-pemfile 2.2.0", "rustls-pki-types", "serde", @@ -8564,9 +8594,9 @@ dependencies = [ [[package]] name = "time" -version = "0.3.37" +version = "0.3.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35e7868883861bd0e56d9ac6efcaaca0d6d5d82a2a7ec8209ff492c07cf37b21" +checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40" dependencies = [ "deranged", "itoa", @@ -8582,15 +8612,15 @@ dependencies = [ [[package]] name = "time-core" -version = "0.1.2" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ef927ca75afb808a4d64dd374f00a2adf8d0fcff8e7b184af886c3c87ec4a3f3" +checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c" [[package]] name = "time-macros" -version = "0.2.19" +version = "0.2.22" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2834e6017e3e5e4b9834939793b282bc03b37a3336245fa820e35e233e2a85de" +checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49" dependencies = [ "num-conv", "time-core", @@ -8758,7 +8788,7 @@ version = "0.26.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5f6d0975eaace0cf0fcadee4e4aaa5da15b5c079146f2cffb67c113be122bf37" dependencies = [ - "rustls 0.23.20", + "rustls 0.23.25", "tokio", ] @@ -9204,7 +9234,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97fee6b57c6a41524a810daee9286c02d7752c4253064d0b05472833a438f675" dependencies = [ "cfg-if 1.0.0", - "rand 0.8.5", + "rand 0.7.3", "static_assertions", ] @@ -9968,19 +9998,6 @@ dependencies = [ "serde", ] -[[package]] -name = "wasmparser" -version = "0.226.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bc28600dcb2ba68d7e5f1c3ba4195c2bddc918c0243fd702d0b6dbd05689b681" -dependencies = [ - "bitflags 2.6.0", - "hashbrown 0.15.2", - "indexmap 2.7.0", - "semver", - "serde", -] - [[package]] name = "wasmparser" version = "0.227.1" @@ -9988,8 +10005,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0f51cad774fb3c9461ab9bccc9c62dfb7388397b5deda31bf40e8108ccd678b2" dependencies = [ "bitflags 2.6.0", + "hashbrown 0.15.2", "indexmap 2.7.0", "semver", + "serde", ] [[package]] diff --git a/containerd-shim-spin/Cargo.toml b/containerd-shim-spin/Cargo.toml index 02350e20..7efcc784 100644 --- a/containerd-shim-spin/Cargo.toml +++ b/containerd-shim-spin/Cargo.toml @@ -11,11 +11,9 @@ Containerd shim for running Spin workloads. """ [dependencies] -containerd-shim-wasm = { version ="0.10.0", default-features = false, features = ["opentelemetry"]} -http = "1" +containerd-shim-wasm = { version = "1.0.0-rc.1", default-features = false, features = ["opentelemetry"]} log = "0.4" spin-app = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } -spin-core = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } spin-componentize = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } # Enable loading components precompiled by the shim spin-trigger = { git = "https://github.com/spinframework/spin", tag = "v3.2.0", features = [ @@ -26,22 +24,13 @@ spin-trigger-redis = { git = "https://github.com/spinframework/spin", tag = "v3. trigger-mqtt = { git = "https://github.com/spinframework/spin-trigger-mqtt", tag = "v0.4.0" } trigger-sqs = { git = "https://github.com/spinframework/spin-trigger-sqs", tag = "v0.9.0" } trigger-command = { git = "https://github.com/spinframework/spin-trigger-command", tag = "v0.3.0" } -spin-manifest = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } spin-loader = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } spin-oci = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } -spin-common = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } -spin-expressions = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } -spin-factors-executor = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } spin-telemetry = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } spin-runtime-factors = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } -spin-factors = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } spin-factor-outbound-networking = { git = "https://github.com/spinframework/spin", tag = "v3.2.0" } wasmtime = "29.0.1" -tokio = { version = "1", features = ["rt"] } openssl = { version = "*", features = ["vendored"] } -serde = "1.0" -serde_json = "1.0" -url = "2.5" anyhow = "1.0" oci-spec = "0.7" futures = "0.3" @@ -52,3 +41,4 @@ wat = "1" temp-env = "0.3.6" toml = "0.8" tempfile = "3" +tokio = { version = "1", features = ["rt"] } \ No newline at end of file diff --git a/containerd-shim-spin/src/engine.rs b/containerd-shim-spin/src/engine.rs index 2de2b8ca..6f673b2d 100644 --- a/containerd-shim-spin/src/engine.rs +++ b/containerd-shim-spin/src/engine.rs @@ -1,14 +1,12 @@ -use std::{ - collections::{hash_map::DefaultHasher, HashSet}, - env, - hash::{Hash, Hasher}, -}; +use std::{collections::HashSet, env, hash::Hash}; use anyhow::{Context, Result}; use containerd_shim_wasm::{ - container::{Engine, RuntimeContext}, - sandbox::WasmLayer, - version, + sandbox::{ + context::{RuntimeContext, WasmLayer}, + Sandbox, + }, + shim::{version, Compiler, Shim, Version}, }; use futures::future; use log::info; @@ -17,7 +15,6 @@ use spin_factor_outbound_networking::validate_service_chaining_for_components; use spin_trigger::cli::NoCliArgs; use spin_trigger_http::HttpTrigger; use spin_trigger_redis::RedisTrigger; -use tokio::runtime::Runtime; use trigger_command::CommandTrigger; use trigger_mqtt::MqttTrigger; use trigger_sqs::SqsTrigger; @@ -35,13 +32,34 @@ use crate::{ }, }; -#[derive(Clone)] -pub struct SpinEngine { - pub(crate) wasmtime_engine: wasmtime::Engine, -} +pub struct SpinShim; +pub struct SpinCompiler(wasmtime::Engine); + +#[derive(Default)] +pub struct SpinSandbox; + +impl Shim for SpinShim { + type Sandbox = SpinSandbox; + + fn name() -> &'static str { + "spin" + } + + fn version() -> Version { + version!() + } -impl Default for SpinEngine { - fn default() -> Self { + fn supported_layers_types() -> &'static [&'static str] { + &[ + constants::OCI_LAYER_MEDIA_TYPE_WASM, + spin_oci::client::ARCHIVE_MEDIATYPE, + spin_oci::client::DATA_MEDIATYPE, + spin_oci::client::SPIN_APPLICATION_MEDIA_TYPE, + ] + } + + #[allow(refining_impl_trait)] + async fn compiler() -> Option { // the host expects epoch interruption to be enabled, so this has to be // turned on for the components we compile. let mut config = wasmtime::Config::default(); @@ -50,18 +68,12 @@ impl Default for SpinEngine { // TODO: This can be removed once the Wasmtime fix is brought into Spin // Issue to track: https://github.com/fermyon/spin/issues/2889 config.native_unwind_info(false); - Self { - wasmtime_engine: wasmtime::Engine::new(&config).unwrap(), - } + Some(SpinCompiler(wasmtime::Engine::new(&config).unwrap())) } } -impl Engine for SpinEngine { - fn name() -> &'static str { - "spin" - } - - fn run_wasi(&self, ctx: &impl RuntimeContext) -> Result { +impl Sandbox for SpinSandbox { + async fn run_wasi(&self, ctx: &impl RuntimeContext) -> Result { // Set the container environment variables which will be collected by Spin's // [environment variable provider]. We use these variables to configure both the Spin runtime // and the Spin application per the [SKIP 003] proposal. @@ -77,12 +89,11 @@ impl Engine for SpinEngine { }); info!("setting up wasi"); - let rt = Runtime::new().context("failed to create runtime")?; let (abortable, abort_handle) = futures::future::abortable(self.wasm_exec_async(ctx)); ctrlc::set_handler(move || abort_handle.abort())?; - match rt.block_on(abortable) { + match abortable.await { Ok(Ok(())) => { info!("run_wasi shut down: exiting"); Ok(0) @@ -98,59 +109,12 @@ impl Engine for SpinEngine { } } - fn can_handle(&self, _ctx: &impl RuntimeContext) -> Result<()> { + async fn can_handle(&self, _ctx: &impl RuntimeContext) -> Result<()> { Ok(()) } - - fn supported_layers_types() -> &'static [&'static str] { - &[ - constants::OCI_LAYER_MEDIA_TYPE_WASM, - spin_oci::client::ARCHIVE_MEDIATYPE, - spin_oci::client::DATA_MEDIATYPE, - spin_oci::client::SPIN_APPLICATION_MEDIA_TYPE, - ] - } - - fn precompile(&self, layers: &[WasmLayer]) -> Result>>> { - // Runwasi expects layers to be returned in the same order, so wrap each layer in an option, setting non Wasm layers to None - let precompiled_layers = layers - .iter() - .map(|layer| match is_wasm_content(layer) { - Some(wasm_layer) => { - log::info!( - "Precompile called for wasm layer {:?}", - wasm_layer.config.digest() - ); - if self - .wasmtime_engine - .detect_precompiled(&wasm_layer.layer) - .is_some() - { - log::info!("Layer already precompiled {:?}", wasm_layer.config.digest()); - Ok(Some(wasm_layer.layer)) - } else { - let component = - spin_componentize::componentize_if_necessary(&wasm_layer.layer)?; - let precompiled = self.wasmtime_engine.precompile_component(&component)?; - Ok(Some(precompiled)) - } - } - None => Ok(None), - }) - .collect::>()?; - Ok(precompiled_layers) - } - - fn can_precompile(&self) -> Option { - let mut hasher = DefaultHasher::new(); - self.wasmtime_engine - .precompile_compatibility_hash() - .hash(&mut hasher); - Some(hasher.finish().to_string()) - } } -impl SpinEngine { +impl SpinSandbox { async fn wasm_exec_async(&self, ctx: &impl RuntimeContext) -> Result<()> { let cache = initialize_cache().await?; let app_source = Source::from_ctx(ctx, &cache).await?; @@ -174,7 +138,7 @@ impl SpinEngine { configure_application_variables_from_environment_variables(&locked_app)?; let trigger_cmds = get_supported_triggers(&locked_app) .with_context(|| format!("Couldn't find trigger executor for {app_source:?}"))?; - let _telemetry_guard = spin_telemetry::init(version!().to_string())?; + let _telemetry_guard = spin_telemetry::init(version!().version.to_string())?; self.run_trigger(ctx, &trigger_cmds, locked_app, app_source) .await @@ -254,6 +218,38 @@ impl SpinEngine { } } +impl Compiler for SpinCompiler { + fn cache_key(&self) -> impl Hash { + self.0.precompile_compatibility_hash() + } + + async fn compile(&self, layers: &[WasmLayer]) -> Result>>> { + // Runwasi expects layers to be returned in the same order, so wrap each layer in an option, setting non Wasm layers to None + let precompiled_layers = layers + .iter() + .map(|layer| match is_wasm_content(layer) { + Some(wasm_layer) => { + log::info!( + "Precompile called for wasm layer {:?}", + wasm_layer.config.digest() + ); + if self.0.detect_precompiled(&wasm_layer.layer).is_some() { + log::info!("Layer already precompiled {:?}", wasm_layer.config.digest()); + Ok(Some(wasm_layer.layer)) + } else { + let component = + spin_componentize::componentize_if_necessary(&wasm_layer.layer)?; + let precompiled = self.0.precompile_component(&component)?; + Ok(Some(precompiled)) + } + } + None => Ok(None), + }) + .collect::>()?; + Ok(precompiled_layers) + } +} + #[cfg(test)] mod tests { use std::str::FromStr as _; @@ -262,8 +258,8 @@ mod tests { use super::*; - #[test] - fn precompile() { + #[tokio::test] + async fn precompile() { let module = wat::parse_str("(module)").unwrap(); let wasmtime_engine = wasmtime::Engine::default(); let component = wasmtime::component::Component::new(&wasmtime_engine, "(component)") @@ -308,10 +304,11 @@ mod tests { ), }, ]; - let spin_engine = SpinEngine::default(); - let precompiled = spin_engine - .precompile(&wasm_layers) - .expect("precompile failed"); + let compiler = SpinCompiler(wasmtime_engine); + let precompiled = compiler + .compile(&wasm_layers) + .await + .expect("compile failed"); assert_eq!(precompiled.len(), 3); assert_ne!(precompiled[0].as_deref().expect("no first entry"), module); assert_eq!( diff --git a/containerd-shim-spin/src/main.rs b/containerd-shim-spin/src/main.rs index a8d454b3..28ccb526 100644 --- a/containerd-shim-spin/src/main.rs +++ b/containerd-shim-spin/src/main.rs @@ -1,8 +1,5 @@ -use containerd_shim_wasm::{ - container::Instance, - sandbox::cli::{revision, shim_main, version}, - Config, -}; +use containerd_shim_wasm::shim::{Cli, Config}; +use engine::SpinShim; mod constants; mod engine; @@ -16,11 +13,5 @@ fn main() { default_log_level: "error".to_string(), ..Default::default() }; - shim_main::>( - "spin", - version!(), - revision!(), - "v2", - Some(shim_config), - ); + SpinShim::run(shim_config); } diff --git a/containerd-shim-spin/src/source.rs b/containerd-shim-spin/src/source.rs index fde89703..49161928 100644 --- a/containerd-shim-spin/src/source.rs +++ b/containerd-shim-spin/src/source.rs @@ -1,7 +1,7 @@ use std::{fs::File, io::Write, path::PathBuf}; use anyhow::{Context, Result}; -use containerd_shim_wasm::container::RuntimeContext; +use containerd_shim_wasm::sandbox::context::RuntimeContext; use log::info; use oci_spec::image::MediaType; use spin_app::locked::LockedApp; @@ -27,10 +27,10 @@ impl std::fmt::Debug for Source { impl Source { pub(crate) async fn from_ctx(ctx: &impl RuntimeContext, cache: &Cache) -> Result { match ctx.entrypoint().source { - containerd_shim_wasm::container::Source::File(_) => { + containerd_shim_wasm::sandbox::context::Source::File(_) => { Ok(Source::File(constants::SPIN_MANIFEST_FILE_PATH.into())) } - containerd_shim_wasm::container::Source::Oci(layers) => { + containerd_shim_wasm::sandbox::context::Source::Oci(layers) => { info!(" >>> configuring spin oci application {}", layers.len()); for layer in layers { diff --git a/containerd-shim-spin/src/trigger.rs b/containerd-shim-spin/src/trigger.rs index 76784f04..8b2cf3e5 100644 --- a/containerd-shim-spin/src/trigger.rs +++ b/containerd-shim-spin/src/trigger.rs @@ -1,5 +1,7 @@ -use std::{collections::HashSet, future::Future, path::Path, pin::Pin}; +use std::{collections::HashSet, path::Path}; +use anyhow::Result; +use futures::{future::BoxFuture, FutureExt}; use log::info; use spin_app::{locked::LockedApp, App}; use spin_runtime_factors::{FactorsBuilder, TriggerFactors}; @@ -27,7 +29,7 @@ pub(crate) async fn run( cli_args: T::CliArgs, app: App, loader: &ComponentLoader, -) -> anyhow::Result>>>> +) -> Result>> where T: Trigger + 'static, { @@ -38,7 +40,7 @@ where let future = builder .run(app, factors_config(), Default::default(), loader) .await?; - Ok(Box::pin(future)) + Ok(future.boxed()) } /// Configuration for the factors. diff --git a/containerd-shim-spin/src/utils.rs b/containerd-shim-spin/src/utils.rs index e0969e08..2b51f43a 100644 --- a/containerd-shim-spin/src/utils.rs +++ b/containerd-shim-spin/src/utils.rs @@ -5,7 +5,7 @@ use std::{ }; use anyhow::{anyhow, Context, Result}; -use containerd_shim_wasm::sandbox::WasmLayer; +use containerd_shim_wasm::sandbox::context::WasmLayer; use oci_spec::image::MediaType; use spin_app::locked::LockedApp; use spin_loader::cache::Cache; diff --git a/node-installer/script/installer.sh b/node-installer/script/installer.sh index f48e6a98..f33f777f 100755 --- a/node-installer/script/installer.sh +++ b/node-installer/script/installer.sh @@ -66,7 +66,7 @@ cp /assets/containerd-shim-spin-v2 $NODE_ROOT$KWASM_DIR/bin/ # A bug in containerd makes BinaryName not work with shim not in PATH, so this statically links the kwasm installation to path # https://github.com/containerd/containerd/issues/11480 mkdir -p $NODE_ROOT/usr/local/bin/ -ln -s $KWASM_DIR/bin/containerd-shim-spin-v2 $NODE_ROOT/usr/local/bin/containerd-shim-spin +ln -s $KWASM_DIR/bin/containerd-shim-spin-v2 $NODE_ROOT/usr/local/bin/containerd-shim-spin-v2 # K3S and RKE2 can detect spin shim themselves, no need to configure # https://github.com/k3s-io/k3s/pull/9519 diff --git a/node-installer/tests/integration-test-k3s.sh b/node-installer/tests/integration-test-k3s.sh index 1974b379..791bd269 100755 --- a/node-installer/tests/integration-test-k3s.sh +++ b/node-installer/tests/integration-test-k3s.sh @@ -42,7 +42,7 @@ echo "Waiting for node installer job to complete..." kubectl wait -n kwasm --for=jsonpath='{.status.phase}'=Succeeded pod --selector=job-name=k3s-provision-kwasm --timeout=60s # Verify the SystemdCgroup is set to true -if sudo cat /var/lib/rancher/k3s/agent/etc/containerd/config.toml | grep -A2 "runtimes.spin.options" | grep -q "SystemdCgroup = true"; then +if sudo cat /var/lib/rancher/k3s/agent/etc/containerd/config.toml | grep -A2 -E "runtimes\.(spin|'spin'|\"spin\")\.options" | grep -q "SystemdCgroup = true"; then echo "SystemdCgroup is set to true" else echo "SystemdCgroup is not set to true"