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

Finally, remove anyhow from the libcontainer dependency. #1937

Merged
merged 7 commits into from
May 19, 2023

Conversation

yihuaf
Copy link
Collaborator

@yihuaf yihuaf commented May 17, 2023

This is the final PR that implements the thiserror in libcontainer. Fix #1377

@yihuaf yihuaf self-assigned this May 17, 2023
@codecov-commenter
Copy link

codecov-commenter commented May 17, 2023

Codecov Report

Merging #1937 (a286eb6) into main (ca6bc31) will increase coverage by 0.01%.
The diff coverage is 0.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1937      +/-   ##
==========================================
+ Coverage   64.86%   64.88%   +0.01%     
==========================================
  Files         127      127              
  Lines       14680    14674       -6     
==========================================
- Hits         9522     9521       -1     
+ Misses       5158     5153       -5     

@yihuaf yihuaf requested review from utam0k and a team May 17, 2023 23:15

// Catch all errors that are not covered by the above
#[error("syscall error")]
OtherSyscall(#[source] nix::Error),
#[error("IO error")]
OtherIO(#[source] std::io::Error),
#[error("Serialization error")]
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
#[error("Serialization error")]
#[error("serialization error")]

impl Executor for WasmEdgeExecutor {
fn exec(&self, spec: &Spec) -> Result<()> {
impl WasmEdgeExecutor {
fn exec_inner(spec: &Spec) -> anyhow::Result<()> {
Copy link
Member

Choose a reason for hiding this comment

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

Why don't we use this error here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is mostly to minimize the changes since the original code uses anyhow. The implementation of the 3 wasm executor is implemented in youki, not libcontainer, so there is no hard requirement to remove anyhow. I was not sure how best to approach this so I wrapped the original implementation into the exec_inner and only map_err once to meet the trait requirement of Executor.

I also wasn't sure how best to implement the Executor trait and the interface libcontainer should provide. This PR does the minimal so there are still rooms for improvement. I have a vague plan to implement the Executor trait with an Error associated type, so the implementation can provide whatever error type they wish. However, this proves to be tricky because we need to store the Executor in ContainerBuilder and ContainerArgs. I could not figure out how to store a trait object with unknown associated type yet. Perhaps the new Generic Associated Type can be of some help. In the end, I decided to keep things simple for now to get this PR merged, and then we can figure out how best to approach this.

On a different note, I suspect that Executor interface can become a great thing for youki and libcontainer, because it opens up a lot of possibility. Currently, we switching the the default execvp calls for the wasm calls. I can also switching the default execvp to run an arbitrary rust function. This would allow us to better and easier testing the libcontainer directly, without the full setup of the oci bundle.

This is a long winded way to answer your question :) But I can certainly remove the anyhow from these executor as well.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done. Fixed these wasm executor not using anyhow.

yihuaf added 7 commits May 18, 2023 09:35
Signed-off-by: yihuaf <[email protected]>
Signed-off-by: yihuaf <[email protected]>
Signed-off-by: yihuaf <[email protected]>
Signed-off-by: yihuaf <[email protected]>
Signed-off-by: yihuaf <[email protected]>
@yihuaf yihuaf force-pushed the yihuaf/remove-anyhow branch from 5437190 to a286eb6 Compare May 18, 2023 20:44
@yihuaf yihuaf requested a review from utam0k May 19, 2023 04:44
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.

🎉🎉🎉🎉🎉🎉

@utam0k utam0k merged commit 0d6b0d5 into youki-dev:main May 19, 2023
@utam0k
Copy link
Member

utam0k commented May 19, 2023

@yihuaf Thanks a lot 🙏

@yihuaf yihuaf deleted the yihuaf/remove-anyhow branch June 13, 2023 20:19
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.

Investigate to use thiserror in our crates
3 participants