Skip to content

Add OCI spec aware compiler hook (for precompile)#1128

Merged
jsturtevant merged 1 commit into
containerd:mainfrom
tanishiking:config-spec
Jun 13, 2026
Merged

Add OCI spec aware compiler hook (for precompile)#1128
jsturtevant merged 1 commit into
containerd:mainfrom
tanishiking:config-spec

Conversation

@tanishiking

Copy link
Copy Markdown
Contributor

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.

Concerns, 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.

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.
@jsturtevant

Copy link
Copy Markdown
Contributor

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 async fn compiler on the trait? Could you read that file then and hand back the properly configured compiler?

@tanishiking

Copy link
Copy Markdown
Contributor Author

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?

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.
Aat precompile time, the container mounts are not available via the container-visible path (/runtime/wasmtime.toml in spinframework/containerd-shim-spin#444), so the shim needs to use the OCI spec to resolve where the configuration file is located on the node.

I think you have that information when we call async fn compiler on the trait? Could you read that file then and hand back the properly configured compiler?

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.

  • runwasi have that information (cfg.bundle) at the call site.
  • However, the current Shim::compiler() API does not pass any spec information to the shim.
  • Therefore, containerd-shim-spin cannot create a "properly configured compiler": it does not know where the Wasmtime configuration file is on the node.

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.
Is there a way for the shim (containerd-shim-spin) to access the OCI spec during precompilation, or to locate the file created from the ConfigMap on the node, without making any changes to runwasi ?

@jsturtevant

Copy link
Copy Markdown
Contributor

Thanks, its been awhile but what you've described sounds right.

Is there a way for the shim (containerd-shim-spin) to access the OCI spec during precompilation, or to locate the file created from the ConfigMap on the node, without making any changes to runwasi ?

I think using the higher level trait in containerd-shim-spin means you don't have access to this. In a prior version the shims had a bit more information.

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.

@jprendes jprendes left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jsturtevant jsturtevant merged commit c28b25d into containerd:main Jun 13, 2026
67 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants