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

Use youki's libcontainer APIs to implement wasmtime shim. #142

Merged
merged 36 commits into from
Jul 10, 2023

Conversation

Mossaka
Copy link
Member

@Mossaka Mossaka commented Jun 13, 2023

  • Implement Executor trait for wasmtime executor.
  • Use libcontainer's lifecycle APIs to implement runwasi's Instance
    trait.

PTAL @utam0k

image

TODO

  • refactor out common functions from both wasmedge and wasmtime shims
  • figure out how to pass the "test_delete_after_create" test
  • figure out how to pass the "test_wasi" test
  • add more tests

Since youki now uses thiserror instead of anyhow, this PR
also updates the containerd-shim-wasmedge to properly map
the error.

Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
- Implement Executor trait for wasmtime executor.
- Use libcontainer's lifecycle APIs to implement runwasi's Instance
  trait.

Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
@Mossaka Mossaka marked this pull request as draft June 13, 2023 23:53
@Mossaka Mossaka linked an issue Jun 13, 2023 that may be closed by this pull request
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
@utam0k
Copy link
Member

utam0k commented Jun 14, 2023

@Mossaka Do you want me to review this PR?

@Mossaka
Copy link
Member Author

Mossaka commented Jun 14, 2023

@Mossaka Do you want me to review this PR?

I would appreciate your feedback once this PR is ready to review :)

Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
@Mossaka Mossaka marked this pull request as ready for review June 21, 2023 17:57
The purpose of this crate is to provide common helper functionalities to
shim implementors that use youki's libcontainer crate. Notice that
the "containerd-shim-wasm" crate does not depend on libcontainer.

This commit refactors shared implementation from the wasmtime
and wasmedge shims to the newly created common crate.

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

Mossaka commented Jun 21, 2023

This PR is ready to review for now. The test_wasi test is still failing with the following message:

Error: Any(failed to receive. "waiting for init ready". BrokenChannel

Caused by:
    channel connection broken)

Copy link
Contributor

@jsturtevant jsturtevant left a comment

Choose a reason for hiding this comment

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

Looks great, I am looking with an eye towards how this would work when Windows is added and I think this actually makes a few things easier. The awkward part might be re-using the WasmtimeExecutor directly vs via a youki Container since Windows isn't supported in youki but I think it will work.

crates/common/Cargo.toml Outdated Show resolved Hide resolved
crates/containerd-shim-wasmedge/src/instance.rs Outdated Show resolved Hide resolved
crates/containerd-shim-wasmtime/src/instance.rs Outdated Show resolved Hide resolved
Ok(_) => 0,
Err(e) => {
if e == Errno::ECHILD {
0
Copy link
Member

Choose a reason for hiding this comment

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

I assume this code came from my code, but it has to plant the log in this case.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could you elaborate more about "plant the log"? Do you want me to log a message when Errno::ECHILD was returned?

Copy link
Member

Choose a reason for hiding this comment

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

when Errno::ECHILD was returned?

Yes 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

I have added a log messaging saying "no child process" when Errno::ECHILD was returned in both the shims.

Copy link
Member Author

Choose a reason for hiding this comment

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

I am not entirely sure when people see this log message, that actions they can do to mitigate. Or is this an issue at all in the first place? I would appreciate if anyone can help me to understand it.

Co-authored-by: Toru Komatsu <k0ma@utam0k.jp>
Signed-off-by: Jiaxiao Zhou <duibao55328@gmail.com>
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
@Mossaka
Copy link
Member Author

Mossaka commented Jul 5, 2023

All the tests are passing 🥳

Copy link
Contributor

@danbugs danbugs left a comment

Choose a reason for hiding this comment

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

LGTM, Joe – just some small comments here and there.

Mossaka and others added 4 commits July 6, 2023 21:53
…hims

Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
Co-authored-by: Dan Chiarlone <danilochiarlone@gmail.com>
Signed-off-by: Jiaxiao Zhou <duibao55328@gmail.com>
@Mossaka Mossaka requested review from danbugs and arschles July 6, 2023 22:23
Signed-off-by: jiaxiao zhou <jiazho@microsoft.com>
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.

LGTM

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

Mossaka commented Jul 7, 2023

Could you please take another look? 🙏 @utam0k , @ipuustin , @cpuguy83

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

@utam0k utam0k left a comment

Choose a reason for hiding this comment

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

Looks good to me, but This PR introduces a big change, so I recommend getting one more approval.

@cpuguy83 cpuguy83 merged commit 0a5a758 into containerd:main Jul 10, 2023
@Mossaka Mossaka deleted the wasmtime-youki branch July 10, 2023 20:43
@Mossaka
Copy link
Member Author

Mossaka commented Jul 10, 2023

Thanks everyone for reviewing!! 🥂🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
7 participants