Add OCI spec aware compiler hook (for precompile)#1128
Conversation
spinframework/containerd-shim-spin#444 adds Wasmtime TOML feature configuration. Runtime configuration can be provided through a Pod mounted `/runtime/wasmtime.toml` for example, but precompilation currently creates the compiler before the shim has access to the configuration. This commits adds `Shim::compiler_with_spec(&Spec)`. Instance creation now loads `config.json` before loading OCI Wasm layers and passes the spec to the compiler through that new API. Downstream shims precompilation should be able to read the spec to configure the wasmtime engine. Concern, this might add a small per-container-start cost: - we read `config.json` before precopmile - construct a precompiler per container rather than once per shim process.
|
If I understand correctly from spinframework/containerd-shim-spin#444 you using the spec to find the spin toml which contains the wasmtime configuration options? I think you have that information when we call |
Yes, that is what I’m trying to do. I’d like to read the OCI spec to find the path of the Wasmtime configuration file on the node.
Yeah... but IIUC it's not possible with the current API (?). To make it possible, I think we need a new API that passes OCI spec information to the shim.
That's why I’d like to add a new API that passes the OCI spec information to the shim, so that shim can create a properly configured compiler. Please let me know if I’m misunderstanding something. |
|
Thanks, its been awhile but what you've described sounds right.
I think using the higher level trait in There might be other way's we might be able to make this more generic but would need some concentrated effort. So I think I am ok with this as an option now. |
spinframework/containerd-shim-spin#444 adds Wasmtime TOML feature configuration. Runtime configuration can be provided through a Pod mounted
/runtime/wasmtime.tomlfor example, but precompilation currently creates the compiler before the shim has access to the configuration.This commits adds
Shim::compiler_with_spec(&Spec). Instance creation now loadsconfig.jsonbefore loading OCI Wasm layers and passes the spec to the compiler through that new API.Downstream shims precompilation should be able to read the spec to configure the wasmtime engine.
Concerns, this might add a small per-container-start cost: 🤔
config.jsonbefore precopmile