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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Luap99
Copy link

@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 Show resolved Hide resolved
main.go Show resolved Hide resolved
@@ -99,7 +112,7 @@ func (c *Criu) doSwrk(reqType rpc.CriuReqType, opts *rpc.CriuOpts, nfy Notify) e
return nil
}

func (c *Criu) doSwrkWithResp(reqType rpc.CriuReqType, opts *rpc.CriuOpts, nfy Notify, features *rpc.CriuFeatures) (*rpc.CriuResp, error) {
func (c *Criu) doSwrkWithResp(reqType rpc.CriuReqType, opts *rpc.CriuOpts, nfy Notify, features *rpc.CriuFeatures) (_ *rpc.CriuResp, retErr error) {
Copy link
Member

Choose a reason for hiding this comment

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

It might be better to name the first return value as resp, rather than leaving it unnamed.

@Luap99
Copy link
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.

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

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
Signed-off-by: Radostin Stoyanov <rstoyanov@fedoraproject.org>
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.

None yet

3 participants