Skip to content
This repository was archived by the owner on Feb 8, 2021. It is now read-only.

double confirm the process has already been started #286

Merged
merged 1 commit into from
Apr 5, 2017

Conversation

gnawux
Copy link
Member

@gnawux gnawux commented Apr 2, 2017

EDIT: simplified the implementation

Having sent pid, the container might have not been started well, a signal comes at this time may not take into effect. see #285

as described in #285, looks send back pid too early may lead to a race condition
if a signal comes right after the init container request.

In this commit, I try to delay sending back the pid, which is a bit complicated
because the pid can not get with getpid(2) in the child process as it is in a new ns.

Signed-off-by: Wang Xu gnawux@gmail.com

@gnawux
Copy link
Member Author

gnawux commented Apr 2, 2017

jenkins failed due to the serial port breaking issue.

retest this please, hykins

@gnawux gnawux requested a review from laijs April 2, 2017 09:03
@gnawux gnawux changed the title delay send back container pid to init double confirm the process has already been started Apr 3, 2017
@gnawux
Copy link
Member Author

gnawux commented Apr 3, 2017

both jenkins and one job of travis failed due to hyperhq/hyperd#555 , wonder if this patch increases its hit probability.

src/exec.c Outdated
@@ -563,9 +563,14 @@ static void hyper_exec_process(struct hyper_exec *exec, struct stdio_config *io)

setsid();

if (pipe > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

it is always true.

src/exec.c Outdated
@@ -563,9 +563,14 @@ static void hyper_exec_process(struct hyper_exec *exec, struct stdio_config *io)

setsid();

if (pipe > 0) {
//send success notification before stdio was installed, otherwise it will be sent to user tty.
Copy link
Contributor

Choose a reason for hiding this comment

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

otherwise the debug log in hyper_send_type() will be sent to user tty.

}

//two message may come back in reversed sequence
exec->pid = (type == 0) ? cpid : type;
Copy link
Contributor

@laijs laijs Apr 5, 2017

Choose a reason for hiding this comment

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

it is time for converting success-notification-pipes to eventfd....
(not reqired in this pr)

@gnawux
Copy link
Member Author

gnawux commented Apr 5, 2017

retest this please, hykins

src/exec.c Outdated
@@ -581,6 +584,10 @@ static void hyper_exec_process(struct hyper_exec *exec, struct stdio_config *io)
}

exit:
if (pipe > 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

pls remove this check

Copy link
Member Author

Choose a reason for hiding this comment

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

o... missed

Having sent pid, the container might have not been started well, a signal comes at this time may not take into effect. see hyperhq#285

Signed-off-by: Wang Xu <gnawux@gmail.com>
@laijs laijs merged commit b4d4741 into hyperhq:master Apr 5, 2017
@gnawux gnawux deleted the delay_pid branch April 5, 2017 16:57
gnawux added a commit to gnawux/hyperstart that referenced this pull request Apr 20, 2017
backport hyperhq#286 to maintenance_1

Signed-off-by: Wang Xu <gnawux@gmail.com>
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.

2 participants