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

criu swrk: return child error to caller #175

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

Luap99
Copy link
Contributor

@Luap99 Luap99 commented Jun 27, 2024

In the podman CI we are seeing a weird flake during criu version detection[1]. The write to the socket just fails with broken pipe. The logical thing to assume here is that the child exited. However the current code never reports back the child error from wait nor does it try to capture the output from it. This fixes both. The cleanup error is now added to the returned error so the caller sees both.

As errors.Join is used from the std lib bump the minimum go version to 1.20.

[1] containers/podman#18856

go.mod Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
main.go Outdated Show resolved Hide resolved
@Luap99
Copy link
Contributor Author

Luap99 commented Jun 28, 2024

Ok so I understand why the CI tests hang.

When capturing output like this in go, the go std lib creates a pipe that is setup on stout/err in the child. After wait() is called on the child go then tries to read all remaining output from the pipe fd set one stdout/err on the child until EOF. However this has one major problem, when the stdout/err file descriptors in the child are then given to other processes. In the hanging tests case this seems to be in the case of CriuReqType_PAGE_SERVER_CHLD which causes a normal fork in the criu swrk process to create criu: page-server which inherits stdout/err.

https://github.com/checkpoint-restore/criu/blob/bf8c134714d6e041261b5129561eeb49aa734ec1/criu/cr-service.c#L1013

I don't have a good answer for this, either we try to make criu close the std fds (dups them to /dev/null) when it forks that there or we do not capture the output at all. Or maybe we special case CriuReqType_PAGE_SERVER_CHLD to not capture output in only this case but I have no idea about criu at all so I don't know if this would effect more options.

Of course I would like to get the output because without debugging failures is basically impossible.

@rst0git rst0git force-pushed the criu-swrk-err branch 2 times, most recently from 64ad5bb to 202cbba Compare July 15, 2024 21:36
@Luap99
Copy link
Contributor Author

Luap99 commented Jul 17, 2024

@rst0git There is no point in rebasing this. I need an answer on the issue raised above. So either I add a special exclude CriuReqType_PAGE_SERVER_CHLD (not sure if there are more we need to worry about) from output capture or I do not try to capture the output at all. I like the output capture of course.

@rst0git
Copy link
Member

rst0git commented Jul 18, 2024

@Luap99 In general, CRIU writes all output to a log file (e.g., opencontainers/runc@c77aaa3). We don't capture any output from stdout for criu swrk (e.g., libcriu, pycriu), except in runc, where stdin, stdout, and stderr are set to inherit stdio.

@Luap99
Copy link
Contributor Author

Luap99 commented Jul 18, 2024

I am not talking about any container runtime involvement here. The fact is that this library just fails with a useless error (write criu-xprt-cln: broken pipe) when the swrk process fails. I can capture the wait error but than we only get the exit code not whatever errors criu pritned to stderr, i.e.
https://github.com/checkpoint-restore/criu/blob/5c3f6217f44acf1edec57a8abf4edcb624accd6f/lib/c/criu.c#L1398

Are you telling me this library should always create a log when starting the swrk process? And then read this file after wait?

@rst0git
Copy link
Member

rst0git commented Jul 19, 2024

@avagin Do you have any ideas on how we could capture the CRIU logs in go-criu?

For example, the following repository contains a simple program that prints the version of CRIU:
https://github.com/rst0git/test-go-criu-swrk

$ go build
$ ./test-go-criu-swrk 
2024/07/19 14:51:09 31900

If we create the following configuration file, it will cause criu swrk to always fail with an error:

$ echo  test | sudo tee /etc/criu/default.conf
$ criu swrk 2
criu: unrecognized option '--test'
...

However, this error is not captured in stdout/stderr:

$ ./test-go-criu-swrk 
2024/07/19 14:49:53 read criu-xprt-cln: connection reset by peer
criu swrk failed: exit status 1 (<nil>)

A similar problem appears with the CI tests for Podman (containers/podman#18856).

@Luap99
Copy link
Contributor Author

Luap99 commented Jul 19, 2024

Ok I understand now, I got confused by the perror lines then as I assumed they print to stderr but if they redirect it into the a log file then it will not help us.

@Luap99
Copy link
Contributor Author

Luap99 commented Jul 19, 2024

I guess I push my change without the output capture for now, getting a exit status 1 or killed would already tell us more useful things in podman.

In the podman CI we are seeing a weird flake during criu version
detection[1]. The write to the socket just fails with broken pipe.
The logical thing to assume here is that the child exited. However the
current code never reports back the child error from wait. The cleanup
error is now added to the returned error so the caller sees both.

The output is not captured as this causes hangs when the fds are passed
into child processes.

As errors.Join is used from the std lib bump the minimum go version to
1.20.

[1] containers/podman#18856

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Copy link

codecov bot commented Jul 19, 2024

Codecov Report

Attention: Patch coverage is 52.94118% with 8 lines in your changes missing coverage. Please review.

Project coverage is 49.94%. Comparing base (76a006a) to head (1c9f152).
Report is 6 commits behind head on master.

Files Patch % Lines
main.go 50.00% 3 Missing and 3 partials ⚠️
phaul/client.go 60.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #175      +/-   ##
==========================================
- Coverage   50.13%   49.94%   -0.19%     
==========================================
  Files          21       21              
  Lines        1889     1898       +9     
==========================================
+ Hits          947      948       +1     
- Misses        810      814       +4     
- Partials      132      136       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@rst0git rst0git left a comment

Choose a reason for hiding this comment

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

LGTM

@rst0git rst0git merged commit 0879a52 into checkpoint-restore:master Jul 19, 2024
14 of 15 checks passed
@Luap99 Luap99 deleted the criu-swrk-err branch July 19, 2024 15:50
Luap99 added a commit to Luap99/libpod that referenced this pull request Aug 19, 2024
There is no new version yet but we like to use the new code[1] to debug
a flake[2] in the podman CI. It will not fix it but the new error might
give us a better idea what is going on.

[1] checkpoint-restore/go-criu#175
[2] containers#18856

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
edsantiago pushed a commit to edsantiago/libpod that referenced this pull request Aug 19, 2024
There is no new version yet but we like to use the new code[1] to debug
a flake[2] in the podman CI. It will not fix it but the new error might
give us a better idea what is going on.

[1] checkpoint-restore/go-criu#175
[2] containers#18856

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
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