Skip to content

Containerd-Shim: Enabling reading annotations: make annotations public e.g., for containerd-shims#1064

Open
wlkrm wants to merge 2 commits intocontainerd:mainfrom
wlkrm:expose-annotations
Open

Containerd-Shim: Enabling reading annotations: make annotations public e.g., for containerd-shims#1064
wlkrm wants to merge 2 commits intocontainerd:mainfrom
wlkrm:expose-annotations

Conversation

@wlkrm
Copy link

@wlkrm wlkrm commented Feb 23, 2026

I am working on a containerd-shim for wasm, which uses annotations to for some container-specific configuration parameters for the runtime. For this, I need access to the annotations in my Sandbox implementation. For this I am using the cointainerd_shim_wasm.
Effectifly, I run the following containerd command:

	sudo ctr run --rm --annotation --annotation 'my_config_param=example_config_value' runtime=./runwasi-shim localhost/wams-app:latest test2

I would need access to the annotations in the Sandbox run_wasi main function like this:

/// Main entry point. Checks if there are annotations.

use containerd_shim_wasm::{
    sandbox::{
        Sandbox,
        context::{RuntimeContext, WasmBinaryType},
    },
    shim::{Cli, Shim, Version, version},
};

impl Sandbox for MySandbox {    
    async fn run_wasi(&self, ctx: &impl RuntimeContext) -> Result<i32> {
        // Implement your Wasm runtime logic here
        let Entrypoint {
            source,
            func,
            arg0,
            name,
        } = ctx.entrypoint();
        log::info!("func: {}, arg0: {:?}, name: {:?}", func, arg0, name);
        // Access the annotations and do something specific for them
        let annotations = ctx.annotations().clone();

These annotation are very specific to my usecase and are out of scope of usual oci run annotations.

To achieve that, I need access to the currently private annotations.
The PR provides an API call to access them.

EDIT: also fixes two typos in docs.

@wlkrm wlkrm changed the title Enabling reading annotations: make annotations public e.g., for containerd-shims Containerd-Shim: Enabling reading annotations: make annotations public e.g., for containerd-shims Feb 23, 2026
@wlkrm wlkrm force-pushed the expose-annotations branch from 8ebf8d1 to 3d4908a Compare February 23, 2026 20:01
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.

1 participant