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

Investigate to use thiserror in our crates #1377

Closed
9 tasks done
utam0k opened this issue Nov 27, 2022 · 25 comments · Fixed by #1937
Closed
9 tasks done

Investigate to use thiserror in our crates #1377

utam0k opened this issue Nov 27, 2022 · 25 comments · Fixed by #1937
Assignees

Comments

@utam0k
Copy link
Member

utam0k commented Nov 27, 2022

Introduction

Now we are using anyhow everywhere. But It would be better to provide some codes as crates(e.g. libcontainer, libcgroup...). Their crates in their current state are not very user-friendly of error handling.

Goal

Investigate and implement to use of thiserror instead of anyhow in crates

Tracking

Let's do the following order because of the number of codes.

@utam0k
Copy link
Member Author

utam0k commented Nov 27, 2022

@chermehdi I'm happy if you have interested in this issue. But this issue is not easy and take a lof of time to achieve better than other good first issues.

@chermehdi
Copy link
Contributor

Sounds good, let us do them in that order, the first one should give us a pretty good idea about how will the others look like, and how much effort is required as well.

@utam0k
Copy link
Member Author

utam0k commented Nov 28, 2022

@chermehdi That's right, libcontainer is going to be quite large task, so if there is a way to make it divisible that would be nice too. May I assign you? There is no deadline, etc. Of course, I can help you whenever.

@chermehdi
Copy link
Contributor

@utam0k yeah sounds good, just assing me.

@chermehdi
Copy link
Contributor

@utam0k liboci-cli only contains arg definitions for the cli implementation. I don't see any behavior that requires error handling, I am not sure why it was included as part of this issue. Can you clarify?

@utam0k
Copy link
Member Author

utam0k commented Dec 5, 2022

@utam0k liboci-cli only contains arg definitions for the cli implementation. I don't see any behavior that requires error handling, I am not sure why it was included as part of this issue. Can you clarify?

Ops, sorry. You don't need to take it. Let's look into libcgroups.

@chermehdi
Copy link
Contributor

@utam0k Where do we want to use thiserror? I suggest to minimize the changes we only introduce thiserror usage right at the edge of the library and keep error handling internally using anyhow/context. this will minimize the number of changes we have to make.

Another thing that I want us to think about is what is our API boundary, and how we want this to be used as a library.

  • Do we want to provide libcgroups as it's own crate? or will we provide Youki as a library as a whole with the API like createFromSpec, start, stop?

@utam0k
Copy link
Member Author

utam0k commented Feb 25, 2023

@chermehdi Sorry for the late reply.

💯

I suggest to minimize the changes we only introduce thiserror usage right at the edge of the library and keep error handling internally using anyhow/context. t

Ideally, yes. Once this is possible, it can be spun out and offered like containers/oci-spec-rs.

Do we want to provide libcgroups as it's own crate?

@squili
Copy link
Contributor

squili commented Apr 30, 2023

Has there been any progress on this? If not, I'd be happy to help!

@utam0k
Copy link
Member Author

utam0k commented Apr 30, 2023

👋 Hi, @squili. Unfortunately, we don't have any progress. I would like to introduce thiserror with libcgroup and libcontainer. Are you interested?

@squili
Copy link
Contributor

squili commented Apr 30, 2023

Sure, I'd love to help with that!

@utam0k
Copy link
Member Author

utam0k commented Apr 30, 2023

Which crate would you like to choose?

@squili
Copy link
Contributor

squili commented Apr 30, 2023

Looks like libcgroup needs to be first, since it's a dependency of libcontainer

@utam0k
Copy link
Member Author

utam0k commented Apr 30, 2023

@squili
I have given you an issue. If possible, could you please generate a plan and create a list of tasks to be done? This can be made later. Thank you.

@utam0k
Copy link
Member Author

utam0k commented Apr 30, 2023

@chermehdi If you have made any progress, please let me know. I know you are probably very busy.

@squili
Copy link
Contributor

squili commented Apr 30, 2023

Here's the current plan:

  • Add thiserror
  • Add thiserror errors
    • Controllers
      • libcgroups::systemd
      • libcgroups::v1
      • libcgroups::v2
    • Stats providers
      • libcgroups::v1
      • libcgroups::v2
    • Managers
      • libcgroups::systemd
      • libcgroups::v1
      • libcgroups::v2
    • Other non-test
  • Remove anyhow

@utam0k
Copy link
Member Author

utam0k commented Apr 30, 2023

@squili Do you want to create a feature branch?

@squili
Copy link
Contributor

squili commented Apr 30, 2023

I can make a branch on a fork and PR

@squili
Copy link
Contributor

squili commented May 2, 2023

Finished work for libcgroups, ready to review! It still uses anyhow in tests because it's useful for tests, but it's been removed as a dependency for everything else.

@yihuaf
Copy link
Collaborator

yihuaf commented May 3, 2023

@squili Sorry I did not catch this thread. I made #1876 and hope I did not step on your toes.

@utam0k
Copy link
Member Author

utam0k commented May 3, 2023

@yihuaf May I ask you to create TODOs list and share them with @squili ?

@utam0k utam0k assigned chermehdi and yihuaf and unassigned chermehdi May 4, 2023
@yihuaf
Copy link
Collaborator

yihuaf commented May 4, 2023

Here we go.

  • container
  • process (partly done)
  • rootfs
  • seccomp
  • workload
  • apparmor
  • capabilities
  • config
  • hook
  • notify_socket
  • signal
  • tty
  • utils

At the top level, we should have a concrete error type in lib.rs to make libcontainer a stand alone library.

Finally

  • remove anyhow

@squili Let's just leave a note in this thread to coordinate :)

@squili
Copy link
Contributor

squili commented May 4, 2023

@yihuaf ill make sure to leave a note for the things i work on! though im going through a few things right now so it may be a bit

@yihuaf
Copy link
Collaborator

yihuaf commented May 4, 2023

I plan on to work on these today:

apparmor
capabilities
config
hook
notify_socket
signal
tty

#1881

@YJDoc2
Copy link
Collaborator

YJDoc2 commented May 5, 2023

@yihuaf and @squili , thanks for your efforts! May I ask you to add the related PR links (existing and future) in the issue description itself? I think it will help in keeping track of which all PRs were part of this change.

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 a pull request may close this issue.

5 participants