Skip to content
This repository was archived by the owner on Dec 13, 2018. It is now read-only.

Report child error better (and later)#22

Closed
alexlarsson wants to merge 1 commit intodocker-archive:masterfrom
alexlarsson:report-start-error
Closed

Report child error better (and later)#22
alexlarsson wants to merge 1 commit intodocker-archive:masterfrom
alexlarsson:report-start-error

Conversation

@alexlarsson
Copy link
Contributor

We use a unix domain socketpair instead of a pipe for the sync pipe,
which allows us to use two-way shutdown. After sending the
context we shut down the write side which lets the child know
it finished reading.

We then block on a read in the parent for the child closing the file
(ensuring we close our version of it too) to sync for when the child
is finished initializing. If the read is non-empty we assume this
is an error report and fail with an error. Otherwise we continue as
before.

This also means we're now calling back the start callback later,
meaning at that point its more likely to have succeeded, as well as
having consumed all the container resources (like volume mounts,
making it safe to e.g. unmount them when the start callback is
called).

Docker-DCO-1.1-Signed-off-by: Alexander Larsson alexl@redhat.com (github: alexlarsson)

Copy link
Contributor

Choose a reason for hiding this comment

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

Any reason not to let CLOEXEC handle the closing, and really notify the parent that everything has started? This would have the desirable effect of also reporting errors from the following steps to the parent.

FinalizeNamespace would need to be tweaked not to close the pipe to support this, though.

We use a unix domain socketpair instead of a pipe for the sync pipe,
which allows us to use two-way shutdown. After sending the
context we shut down the write side which lets the child know
it finished reading.

We then block on a read in the parent for the child closing the file
(ensuring we close our version of it too) to sync for when the child
is finished initializing. If the read is non-empty we assume this
is an error report and fail with an error. Otherwise we continue as
before.

This also means we're now calling back the start callback later,
meaning at that point its more likely to have succeeded, as well as
having consumed all the container resources (like volume mounts,
making it safe to e.g. unmount them when the start callback is
called).

Docker-DCO-1.1-Signed-off-by: Alexander Larsson <alexl@redhat.com> (github: alexlarsson)
@alexlarsson
Copy link
Contributor Author

New version that relies on the close-on-exec to close the pipe, which means we report more errors. Also fixed the empty line nit.

@alexlarsson
Copy link
Contributor Author

Note: This works because we merged the change to make FinalizeNamespace set cloexec rather than close fds.

@mrunalp
Copy link
Contributor

mrunalp commented Jun 23, 2014

@crosbymichael @vmarmol review please :)

Copy link
Contributor

Choose a reason for hiding this comment

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

nit: ReadFromChild similar to below for parent

@crosbymichael
Copy link
Contributor

I'll take this PR and rebase

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants