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

libcontainer: use OwnedFd as console_socket in ContainerBuilder #2966

Merged
merged 2 commits into from
Nov 25, 2024

Conversation

abel-von
Copy link
Contributor

We found we will get a residual fd in the process to call libcontainer, after we called exec of a container and exit.
and after some investigation, I found it is because the opened console_socket is not closed after exec build.

Copy link
Contributor

@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.

Thanks for working on this @abel-von .
Two of the tests in tty.rs are failing due to these changes.
Would you mind fixing them?

@@ -233,7 +221,7 @@ mod tests {
let lis = UnixListener::bind(&socket_path);
assert!(lis.is_ok());
let fd = setup_console_socket(testdir.path(), &socket_path, CONSOLE_SOCKET);
let status = setup_console(&fd.unwrap());
let status = setup_console(fd.unwrap().as_raw_fd());
Copy link
Contributor

Choose a reason for hiding this comment

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

This test is failing as setup_console is closing the RawFd it receives.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done, changed to into_raw_fd

crates/libcontainer/src/tty.rs Show resolved Hide resolved
@YJDoc2
Copy link
Collaborator

YJDoc2 commented Oct 30, 2024

Hey @abel-von , a separate question - how does this relate to your other PR (#2961) ? Or are these two independent?

@abel-von
Copy link
Contributor Author

Hi @YJDoc2, I think they are independent, we found these issues because we are trying to use libcontainer instead of calling runc binary to manage containers. In our senarios, we have one process in a machine to manage all the containers running on it, so when we call libcontainer to manage containers, we have to make sure no resource residual in this process when a container is removed.

@abel-von
Copy link
Contributor Author

abel-von commented Nov 1, 2024

Two of the tests in tty.rs are failing due to these changes.

Fixed the test if we agree that setup_console_socket return error if the file does not exist. PTAL @jprendes

@YJDoc2 YJDoc2 added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. breaking change labels Nov 4, 2024
@abel-von
Copy link
Contributor Author

@jprendes I think the test is ok now? could you please check this again?

Copy link
Contributor

@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

@jprendes
Copy link
Contributor

@YJDoc2 what makes this a breaking change?
I don't see any change to the public API, I might be missing something.
Never mind, I see, it's the return type on the tty module.

@YJDoc2
Copy link
Collaborator

YJDoc2 commented Nov 23, 2024

@abel-von , may I ask you to resolve the conflict and maybe rebase on main? Thanks

@YJDoc2
Copy link
Collaborator

YJDoc2 commented Nov 25, 2024

@abel-von , may I ask you to resolve the conflict and maybe rebase on main? Thanks

I did a main merge and resolved this, as it was pretty small. Will merge after CI passes.

Thanks for your contribution!

@YJDoc2 YJDoc2 added kind/bug and removed kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. labels Nov 25, 2024
@YJDoc2 YJDoc2 merged commit 5c5cdae into youki-dev:main Nov 25, 2024
29 checks passed
@github-actions github-actions bot mentioned this pull request Nov 25, 2024
@abel-von
Copy link
Contributor Author

Very sorry for the late reply, and thank you very much. @YJDoc2

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

Successfully merging this pull request may close these issues.

4 participants