Skip to content

support to print stack#3667

Closed
ningmingxiao wants to merge 1 commit intoopencontainers:mainfrom
ningmingxiao:dev1
Closed

support to print stack#3667
ningmingxiao wants to merge 1 commit intoopencontainers:mainfrom
ningmingxiao:dev1

Conversation

@ningmingxiao
Copy link
Copy Markdown
Contributor

Signed-off-by: ningmingxiao ning.mingxiao@zte.com.cn
sometimes runc is hanged ,this will show where hang

@ningmingxiao ningmingxiao force-pushed the dev1 branch 4 times, most recently from a1c06f2 to 72a0fc3 Compare November 16, 2022 14:26
Comment thread init.go Outdated
@ningmingxiao ningmingxiao force-pushed the dev1 branch 2 times, most recently from 5f601d8 to cd8064c Compare November 17, 2022 01:13
Comment thread init.go Outdated
@ningmingxiao ningmingxiao force-pushed the dev1 branch 6 times, most recently from c705620 to ebaf740 Compare November 28, 2022 14:40
@ningmingxiao
Copy link
Copy Markdown
Contributor 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor 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 <ning.mingxiao@zte.com.cn>
@kolyshkin
Copy link
Copy Markdown
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