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

support to print stack #3667

Closed
wants to merge 1 commit into from
Closed

Conversation

ningmingxiao
Copy link

Signed-off-by: ningmingxiao [email protected]
sometimes runc is hanged ,this will show where hang

init.go Outdated Show resolved Hide resolved
init.go Outdated Show resolved Hide resolved
@ningmingxiao
Copy link
Author

ningmingxiao commented Nov 28, 2022

but after unix.Close(l.logFd) at standard_init_linux.go , I can't use logrus to print stack, this will miss some messages @kolyshkin

@kolyshkin
Copy link
Contributor

but after unix.Close(l.logFd) at standard_init_linux.go , I can't use logrus to print stack, this will miss some messages @kolyshkin

Yes, since the logs are being forwarded to the parent, the parent has to live until there are logs. Previously (before #2835) sometimes the parent was exiting prematurely, resulting in some logs being lost. Now, we do wait for the child to close the log fd, to make sure all the logs are forwarded.

All it means for this case is it's not possible to use logrus from runc init after closing the logs. I am not sure how to handle this, perhaps the bold approach would be to remove logs forwarding goroutine entirely, instead passing the logrus fd directly to init. This needs some thinking and experimenting though

@kolyshkin
Copy link
Contributor

the bold approach would be to remove logs forwarding goroutine entirely, instead passing the logrus fd directly to init.

This might work, but we need to teach the C code to work the same way as logrus -- meaning, produce either text or json, depending on settings and whether fd is a terminal.

@ningmingxiao
Copy link
Author

the bold approach would be to remove logs forwarding goroutine entirely

I don't understand "the bold approach would be to remove logs forwarding goroutine entirely" can you explain it ?

Signed-off-by: ningmingxiao <[email protected]>
@kolyshkin
Copy link
Contributor

I don't understand "the bold approach would be to remove logs forwarding goroutine entirely" can you explain it ?

For runc init, we use a goroutine that receives log entries from the C code in libcontainer/nsenter and sends them to logrus (see ForwardLogs in libcontainer/logs).

In theory, we can remove this log forwarding, instead passing the log file descriptor to C code, and log directly from there.

@kolyshkin kolyshkin marked this pull request as draft April 11, 2023 23:25
@kolyshkin kolyshkin closed this Aug 1, 2023
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