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

Add LinuxContainerExecutor to Wasmtime and WasmEdge shims #156

Merged
merged 22 commits into from
Aug 14, 2023

Conversation

Mossaka
Copy link
Member

@Mossaka Mossaka commented Jun 23, 2023

This PR adds a LinuxContainerExecutor to both the Wasmtime and Wasmedge shims. It enables the shims to be able to execute containers side by side with wasms.

Some notable changes

  1. It adds a new libcontainer_instance module to containerd-shim-wasm which provides a linux container executor implementation that is shared by both wasmtime and wasmedge shims.
  2. It adds this executor to both the shims.
  3. It adds nginx image to integration tests.

@jsturtevant
Copy link
Contributor

It enables the wasmtime shim to be able to execute linux container if the wasm binary was not found on the rootfs.

We may need to revisit this since #147 would mean the wasm binary would definitely not be in the rootfs

@Mossaka
Copy link
Member Author

Mossaka commented Jun 23, 2023

It enables the wasmtime shim to be able to execute linux container if the wasm binary was not found on the rootfs.

We may need to revisit this since #147 would mean the wasm binary would definitely not be in the rootfs

Yeah we can revisit this once #147 is merged.

@Mossaka Mossaka force-pushed the issue64 branch 3 times, most recently from 4ff9d3c to c9dee9f Compare June 23, 2023 23:30
@Mossaka Mossaka force-pushed the issue64 branch 4 times, most recently from 7cb3119 to 30456c3 Compare July 10, 2023 22:29
This commit implements can_handle in wasmtime executor. It checks
if the entrypoint binary has wasm as the path extension. If not,
the wasmtime executor will not be used.

It adds a default executor to the wasmtime shim as a backup
so it enables running wasm and containers side-by-side.

Add wat extension support in can_handle

Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
this commit adds a python container in the test directory.
It also adds a few commands in the makefile to build the python
flask app into a container, load into the kind cluster for testing.
Eventually the wasmtime tests will have both python container and
a wasm contaienr running in a pod.

Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
The issue says "WARNING: No output specified with docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load"

Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
@Mossaka
Copy link
Member Author

Mossaka commented Jul 13, 2023

Could I please have some review comments on this PR? 🙏🙏

Makefile Outdated Show resolved Hide resolved
test/py-flask/Dockerfile Outdated Show resolved Hide resolved
Copy link

@arschles arschles left a comment

Choose a reason for hiding this comment

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

just one suggestion. otherwise LGTM

crates/containerd-shim-wasmtime/src/instance.rs Outdated Show resolved Hide resolved
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
@cpuguy83
Copy link
Member

Looking through youki a bit, I think can_handle is not part of the executor interface and instead it is expected that we call can_handle from within exec() and return an appropriate error if it can't be used.

@0xE282B0
Copy link
Contributor

@cpuguy83, yes that was refactored lately. There is #209 to adapt to the new interface.

@Mossaka
Copy link
Member Author

Mossaka commented Aug 10, 2023

I think can_handle is not part of the executor interface and instead it is expected that we call can_handle from within exec() and return an appropriate error if it can't be used.

Yeah, as @0xE282B0 mentioned, this was the latest breaking change post v0.1.0 of libcontainer and we are still depending on the released version so we will deal with the refactoring later at #209.

Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
@Mossaka
Copy link
Member Author

Mossaka commented Aug 14, 2023

I've updated this PR to add linux container executors to both Wasmtime and WasmEdge shims.

@Mossaka Mossaka changed the title Add DefaultExecutor to wasmtime shim to enable linux containers Add LinuxContainerExecutor to Wasmtime and WasmEdge shims Aug 14, 2023
this commits adds the default executor to the wasmedge shim similar to how
wasmtime shim gets it. It made an API change to the containerd-shim-wasm crate
by moving default executor logic from wasmtime shim upstream for sharing code.

Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
@Mossaka Mossaka merged commit 78db911 into containerd:main Aug 14, 2023
7 checks passed
@Mossaka Mossaka deleted the issue64 branch August 14, 2023 23:27
@Mossaka
Copy link
Member Author

Mossaka commented Aug 14, 2023

Hey thanks everyone for reviewing this PR! 🙌🥂 I realized it's very difficult to squash commits before merge so I did a squash merge all together to make main branch clean. We can set a policy to only allow squash merge, wdyt? @jsturtevant

jsturtevant added a commit to jsturtevant/runwasi that referenced this pull request Aug 15, 2023
Signed-off-by: James Sturtevant <jstur@microsoft.com>
jsturtevant added a commit to jsturtevant/runwasi that referenced this pull request Aug 15, 2023
Signed-off-by: James Sturtevant <jstur@microsoft.com>
jsturtevant added a commit to jsturtevant/runwasi that referenced this pull request Aug 15, 2023
Signed-off-by: James Sturtevant <jstur@microsoft.com>
jsturtevant added a commit to jsturtevant/runwasi that referenced this pull request Aug 16, 2023
Signed-off-by: James Sturtevant <jstur@microsoft.com>
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.

8 participants