Repository navigation
wasm: adds support to natively build and run wasm workload and wasm containers - #742
Conversation
|
/hold till TODO |
dfa77a9 to
3e5f286
Compare
47eea8a to
c08b3c2
Compare
|
Just need to add a working example. |
532b3bb to
366bcca
Compare
giuseppe
left a comment
There was a problem hiding this comment.
great work!
Just some minor comments
| size_t lensuffix = strlen (suffix); | ||
| if (lensuffix > lenstr) | ||
| return 0; | ||
| return strncmp (str + lenstr - lensuffix, suffix, lensuffix) == 0; |
There was a problem hiding this comment.
should we use memcmp here since you've already calculated the length?
There was a problem hiding this comment.
thanks fixed in latest commit.
| } | ||
| ``` | ||
| * Compile to `wasm32-wasi` target using `wasm-pack` or any other relevent tool. We are going to be using `cargo build --target wasm32-wasi` | ||
| * Create relevent image and use your container manager. But for this example we will be running directly using crun and plub config manually. |
There was a problem hiding this comment.
how would it be possible to use such example from an OCI image?
Is Buildah able to build an image with a wasm binary that runs automatically with the correct handler?
There was a problem hiding this comment.
Yes running image with build with annotation buildah build --annotation "module.wasm.image/variant=compat" -t mywasm . or buildah build --annotation "run.oci.handler=wasm" -t mywasm . will switch handlers.
Also added a working example with buildah and podman.
|
I think this is a great feature and we should try to get it into the next release. Do you have a working example of running wasm modules in compatibility mode (from building the image with Buildah to run it with Podman)? |
|
@giuseppe Sure i'll get it in this PR. I still have to rig buildah. |
|
@giuseppe Added a new change for supporting Running image built with annotations
Will switch handlers to Also added a working example with buildah and podman. |
16d038b to
28cdbec
Compare
|
For the CI failure I am fine if we temporarily stick to a working commit in the runtime-tools and later revert the change once it is fixed upstream |
873f3da to
ec924ae
Compare
|
rebased after #762 |
giuseppe
left a comment
There was a problem hiding this comment.
some few minor comments, the one about exec is just to understand what is the plan, probably there is nothing to deal with as part of this PR.
Once these minor comments are addressed, I am fine to merge
| if (data_read_size > 0) | ||
| { | ||
| stdout_size += data_read_size; | ||
| fwrite (buffer, sizeof (char), data_read_size, memory_stream); |
There was a problem hiding this comment.
why do we need to buffer the data? Cannot we just print it as soon as we read it?
There was a problem hiding this comment.
@giuseppe I agree with you on this one but my only concern was to handle NULL before every print. Just relying on module's EOF seemed natural to me. But i will optimize this in a separate PR if that works.
Optimizing this should reduce the use of open_memstream as well.
There was a problem hiding this comment.
Won't that be kept in memory until the container exits? I don't think we can buffer the entire amount of stdout produced and print it only when the container exits
There was a problem hiding this comment.
@giuseppe ackd and makes sense to me. I'll rectify this one.
|
|
||
| { | ||
| FILE *memory_stream; | ||
| char *stdout_ptr; |
There was a problem hiding this comment.
thanks fixed don't know how missed it.
ec924ae to
50596e8
Compare
Signed-off-by: Aditya Rajan <arajan@redhat.com>
Add support to switch handler to "wasm" if annotation `module.wasm.image/variant=compat` is detected. Signed-off-by: Aditya Rajan <arajan@redhat.com>
b7edfad to
7fb04a7
Compare
|
how can we get wasmer on Fedora? @lsm5 do you have any suggestions? |
printf might be adding additional buffering since a level of buffering might be happening at wasm binary itself. Plus safe_write guarantees that we relay binary output as it is without any additional modification or buffering. Signed-off-by: Aditya Rajan <arajan@redhat.com>
7fb04a7 to
952913b
Compare
|
@flouthoc congratulations on moving this major feature to completion! |
|
yay !!!! I'll take @lsm5's help for library distribution. |
|
Now how do we make it useful by integrating it into Podman and then writing a blog explaining what it does. Including the power of crun as an OCI Runtime. |
|
Can you build this out into a Blog where you could actually push the image to a registry so that others could try it out. |
|
the issue is that users need to build a custom crun, since wasmer is not present on Fedora so we cannot build with it. As soon as it is present, I think we should build crun with support for wasm |
|
Is this worth pushing for? |
|
fwiw, i don't yet see any non-rust packages in fedora for a |
|
We would need wasmer's shared library. But I'll check once if its already being distributed with any other packages and will report back. |
Following PR initiates and adds support for crun to be able to build and run wasm/wasi workload in a native manner using `wasmtime`. Crun already supports running `wasm` workload using `wasmer` and `wasmedge` following PR extends this feature so that end-users can switch to `wasmtime`, following feature is proposed inorder to maintain feature parity with other tools in the same space. Ref: * Wasmedge integration: containers#774 * Wasmer integration: containers#742 Signed-off-by: Aditya R <arajan@redhat.com>
Following PR initiates and adds support for crun to be able to build and run wasm/wasi workload in a native manner using `wasmtime`. Crun already supports running `wasm` workload using `wasmer` and `wasmedge` following PR extends this feature so that end-users can switch to `wasmtime`, following feature is proposed inorder to maintain feature parity with other tools in the same space like `krustlet` which rely on `wasmtime` under the hood. Ref: * Wasmedge integration: containers#774 * Wasmer integration: containers#742 * https://github.com/krustlet/krustlet Signed-off-by: Aditya R <arajan@redhat.com>
Following PR initiates and adds support for crun to be able to build and run wasm/wasi workload in a native manner using `wasmtime`. Crun already supports running `wasm` workload using `wasmer` and `wasmedge` following PR extends this feature so that end-users can switch to `wasmtime`, following feature is proposed inorder to maintain feature parity with other tools in the same space like `krustlet` which rely on `wasmtime` under the hood. Ref: * Wasmedge integration: containers#774 * Wasmer integration: containers#742 * https://github.com/krustlet/krustlet Signed-off-by: Aditya R <arajan@redhat.com>
Following PR initiates and adds support for crun to be able to build and run wasm/wasi workload in a native manner using `wasmtime`. Crun already supports running `wasm` workload using `wasmer` and `wasmedge` following PR extends this feature so that end-users can switch to `wasmtime`, following feature is proposed inorder to maintain feature parity with other tools in the same space like `krustlet` which rely on `wasmtime` under the hood. Ref: * Wasmedge integration: containers#774 * Wasmer integration: containers#742 * https://github.com/krustlet/krustlet Signed-off-by: Aditya R <arajan@redhat.com>
Following PR initiates and adds support for crun to be able to build and run wasm/wasi workload in a native manner using `wasmtime`. Crun already supports running `wasm` workload using `wasmer` and `wasmedge` following PR extends this feature so that end-users can switch to `wasmtime`, following feature is proposed inorder to maintain feature parity with other tools in the same space like `krustlet` which rely on `wasmtime` under the hood. Ref: * Wasmedge integration: containers#774 * Wasmer integration: containers#742 * https://github.com/krustlet/krustlet Signed-off-by: Aditya R <arajan@redhat.com>
Following PR initiates and adds support for crun to be able to build and run wasm/wasi workload in a native manner using `wasmtime`. Crun already supports running `wasm` workload using `wasmer` and `wasmedge` following PR extends this feature so that end-users can switch to `wasmtime`, following feature is proposed inorder to maintain feature parity with other tools in the same space like `krustlet` which rely on `wasmtime` under the hood. Ref: * Wasmedge integration: containers#774 * Wasmer integration: containers#742 * https://github.com/krustlet/krustlet Signed-off-by: Aditya R <arajan@redhat.com>
Following PR initiates and adds support for crun to be able to build and
run wasm workload in a native manner. With recent development in wasm and
amalgamation of OCI, crun should be able to build and run wasm workload in
an isolated environment.
Ref:
https://github.com/engineerd/wasm-to-oci
https://www.solo.io/blog/announcing-the-webassembly-wasm-oci-image-spec/
https://github.com/solo-io/wasm/blob/master/spec/spec-compat.md