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

bump libcontainer to tip of tree #290

Merged
merged 4 commits into from
Aug 30, 2023
Merged

Conversation

yihuaf
Copy link
Contributor

@yihuaf yihuaf commented Aug 29, 2023

  • fixed all the api breakage
  • implemented new executor validation logic

- fixed all the api breakage
- implemented new executor validation logic

Signed-off-by: yihuaf <[email protected]>
@yihuaf
Copy link
Contributor Author

yihuaf commented Aug 29, 2023

@jprendes PTAL. This turned out to be a little more code change (wider impact) than I anticipated. Let me know if you would like me to make any change.

fn can_handle(&self, spec: &Spec) -> bool {
// TODO: some of these logic is now implemented inside the default
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should address this TODO before merging.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I think it's ok to completely remove this function now.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are some ELF magic number checking that is specific to runwasi. I decided to leave the function in for now and we can address the duplication in future PR.

@yihuaf
Copy link
Contributor Author

yihuaf commented Aug 29, 2023

One more question, what is the expected behavior of wasm executor when a regular OCI container is passed in? The current implementation will try to check if the container is a wasm container. If not wasm, then we use the default executor to validate or exec. Let me know if this assumption doesn't hold.

Cargo.toml Show resolved Hide resolved
if extension of the binary is incorrect.

Signed-off-by: yihuaf <[email protected]>
@jprendes jprendes closed this Aug 29, 2023
@jprendes jprendes reopened this Aug 29, 2023
fn name(&self) -> &'static str {
EXECUTOR_NAME
fn validate(&self, spec: &Spec) -> std::result::Result<(), ExecutorValidationError> {
match self.can_handle(spec) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: I'm not a huge fan of doing this check twice, here and on exec. But it works.
I'll try to think if we can avoid it or not.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is one of the downside/trade off of this interface. In both valid and exec, we have to run the can_handle logic to figure out the correct exec. Also due to rust safety features, in exec we have to run a lot of the similar checks to return InvalidArg error. For example, if there is no process block in the spec, we have to check it again inside exec even though we already checked in the valid. It doesn't make sense for us to panic.

Mossaka
Mossaka previously approved these changes Aug 30, 2023
Copy link
Member

@Mossaka Mossaka left a comment

Choose a reason for hiding this comment

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

lgtm!

@Mossaka
Copy link
Member

Mossaka commented Aug 30, 2023

Shall I merge or are you working on pushing more commits? @yihuaf

@yihuaf
Copy link
Contributor Author

yihuaf commented Aug 30, 2023

Shall I merge or are you working on pushing more commits? @yihuaf

I have one more to address some of the nits and suggestion. I will let you know when this is ready.

@yihuaf
Copy link
Contributor Author

yihuaf commented Aug 30, 2023

@Mossaka Once CI is green, this is ready for merge.

Copy link
Collaborator

@jprendes jprendes left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @yihuaf !

@Mossaka Mossaka merged commit 6232e5c into containerd:main Aug 30, 2023
13 checks passed
@Mossaka Mossaka mentioned this pull request Aug 30, 2023
@yihuaf yihuaf deleted the yihuaf/youki branch August 30, 2023 19:35
};
let path = PathBuf::from(module_name);
Err(ExecutorValidationError::CantHandle(_)) => {
LinuxContainerExecutor::new(self.stdio.clone()).exec(spec)?;
Copy link
Member

Choose a reason for hiding this comment

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

I realized this changes the behavior of previous runwasi's mechanism. Previously, wasmtime shim first checks if container is a Linux binary, and then check if it's a wasm container.

This logic seems to first check if container is a wasm binary, and then a Linux container.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That's correct.
That's fine in the wasmedge and wasmtime cases where entrypoint should point to wasm files.
For spin/slight/wws the implementation of the executor should be somewhat different.
If you want take a look at the executor in #250, which keeps the old behaviour we has before this PR.

Copy link
Collaborator

Choose a reason for hiding this comment

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

The executor validation of #250 is here

Copy link
Member

@Mossaka Mossaka Aug 31, 2023

Choose a reason for hiding this comment

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

I had a discussion with @cpuguy83 before, and we reached a conclusion that there isn't a robust way to check a wasm text file (wasm binary file could be checkd by verifying its magic number), thus the reason to check if a container is a Linux binary, or otherwise defaults to wasm / wat.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree that the current check (i.e., the module has .wasm or .wat extension is not robust, but I expect it to work in most cases with wasmedge / wasmtime. But I do think we should find a better way.
For wasmedge / wasmtime, once the module is an OCI artifact the discussion will be different.

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.

3 participants