Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consolidate the RuntimeContext API to use one EntryPoint and expose Source for WASI files #398

Merged
merged 3 commits into from
Nov 28, 2023

Conversation

jsturtevant
Copy link
Contributor

This PR makes a few changes to the the RuntimeContext API regarding OCI:

@jsturtevant
Copy link
Contributor Author

The wasmedge error looks like something with k3s, going to re-trigger

NAMESPACE     NAME                                     READY   STATUS              RESTARTS   AGE
kube-system   metrics-server-648b5df564-vfq4j          0/1     Running             0          8s
kube-system   coredns-77ccd57875-zcdxr                 1/1     Running             0          8s
kube-system   local-path-provisioner-957fdf8bc-qdlnl   1/1     Running             0          8s
kube-system   helm-install-traefik-crd-rtw9s           0/1     Completed           0          8s
kube-system   helm-install-traefik-tsb9m               0/1     Error               0          8s
default       wasi-demo-79d9475fd-5bnwj                0/2     ContainerCreating   0          0s
default       wasi-demo-79d9475fd-6tvpx                0/2     ContainerCreating   0          0s
default       wasi-demo-79d9475fd-xl4xf                0/2     ContainerCreating   0          0s

Copy link
Collaborator

@jprendes jprendes left a comment

Choose a reason for hiding this comment

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

Thanks for working on this! :-)

I'm not sure how I feel about WasiLoadingStrategy. I personally would make it part of the entrypoint.

Something like:

pub struct Entrypoint<'a> {
    // The entrypoint function in the wasm module.
    // Usualy "_start".
    pub func: String,

    // A name that can be used to identify the module.
    // Usualy the name of the wasm file.
    pub name: Option<String>,

    // The raw arg0 provived in the OCI spec.
    pub arg0: Option<&'a Path>,

    // The source for the WASI module / components
    pub srouce: WasiSource<'a>,
}

// The source for a WASI module / components.
pub enum WasiSource<'a> {
    // The WASI module is a file in the file system.
    // This case is only valid with WASI preview1 modules.
    File(PathBuf),

    // The WASI module / component is provided in the OCI spec.
    // For a WASI preview 1 module this is usually a single element array.
    // For a WASI preview 2 component this is an array of one or more
    // elements, where each element is a component.
    // Runtimes can additionally provide a list of layer types they support,
    // and they will be included in this array, e.g., a `toml` file with the
    // runtime configuration.
    Oci(&'a [WasmLayer]),    
}

crates/containerd-shim-wasm/src/container/context.rs Outdated Show resolved Hide resolved
crates/containerd-shim-wasm/src/container/context.rs Outdated Show resolved Hide resolved
crates/containerd-shim-wasm/src/container/context.rs Outdated Show resolved Hide resolved
crates/containerd-shim-wasm/src/container/context.rs Outdated Show resolved Hide resolved
crates/containerd-shim-wasm/src/container/context.rs Outdated Show resolved Hide resolved
crates/containerd-shim-wasm/src/container/engine.rs Outdated Show resolved Hide resolved
@jsturtevant
Copy link
Contributor Author

I'm not sure how I feel about WasiLoadingStrategy. I personally would make it part of the entrypoint.

nice! I was struggling with the entrypoint vs loading strategy but hadn't figured it out yet. They shared similar data and logic, I believe your suggestion resolves the dissonance I was feeling. Will give this a go

Signed-off-by: James Sturtevant <[email protected]>
@jsturtevant jsturtevant changed the title Use OCI loading strategy Consolidate the RuntimeContext API to use one EntryPoint and expose Source for WASI files Nov 17, 2023
Copy link
Collaborator

@jprendes jprendes left a comment

Choose a reason for hiding this comment

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

Awesome! Thanks @jsturtevant !
Just two minor nits, and I'm happy for this to be merged :-)

crates/containerd-shim-wasm/src/container/context.rs Outdated Show resolved Hide resolved
crates/containerd-shim-wasmtime/src/instance.rs Outdated Show resolved Hide resolved
Signed-off-by: James Sturtevant <[email protected]>
Copy link
Member

@Mossaka Mossaka left a comment

Choose a reason for hiding this comment

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

Thanks, lgtm!

@Mossaka Mossaka merged commit 3550a2d into containerd:main Nov 28, 2023
43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants