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

fix(api): serve until the "acceptconnections" job #4398

Merged
merged 1 commit into from Mar 3, 2014

Conversation

philips
Copy link
Contributor

@philips philips commented Mar 1, 2014

This fixes a bug that I encountered when using socket activation with docker
0.8.1. When running the first docker run it would return:
"create: command not found".

The root cause was the socket activation code path was starting to listen
before the "initserver" job had finished. This meant that the
"create" handler hand't been registered yet leading to the command not found
error.

In log format it looks like this:

[/var/lib/docker|9d2e78e9] +job initserver() 2014/03/01 04:05:35 Listening for
HTTP on fd ()
[/var/lib/docker|0d71c177] +job create() create: command not found
[/var/lib/docker|0d71c177] -job create()
[/var/lib/docker|0d71c177] +job acceptconnections()
[/var/lib/docker|0d71c177] -job initserver() = OK (0)

To fix the issue select on the activationLock and block until the
"acceptconnections" job has ran.

Docker-DCO-1.1-Signed-off-by: Brandon Philips brandon.philips@coreos.com (github: philips)

// We don't want to start serving on these sockets until the
// "initserver" job has completed. Otherwise required handlers
// won't be ready.
select {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why a select here and not just <-activationLock ?

This fixes a bug that I encountered when using socket activation with
docker 0.8.1. When running the first `docker run` it would return:
"create: command not found".

The root cause was the socket activation code path was starting to
listen before the "initserver" job had finished. This meant that the
"create" handler hand't been registered yet leading to the command not
found error.

In log format it looks like this:

```
[/var/lib/docker|9d2e78e9] +job initserver()
2014/03/01 04:05:35 Listening for HTTP on fd ()
[/var/lib/docker|0d71c177] +job create()
create: command not found
[/var/lib/docker|0d71c177] -job create()
[/var/lib/docker|0d71c177] +job acceptconnections()
[/var/lib/docker|0d71c177] -job initserver() = OK (0)
```

To fix the issue select on the activationLock and block until the
"acceptconnections" job has ran.

Docker-DCO-1.1-Signed-off-by: Brandon Philips <brandon.philips@coreos.com> (github: philips)
@philips
Copy link
Contributor Author

philips commented Mar 1, 2014

@crosbymichael Fixed in 8d2226b. Thanks for catching that; it was left over from understanding the listenbuffer. Should be good now.

@crosbymichael
Copy link
Contributor

LGTM

@crosbymichael crosbymichael added this to the 0.9.0 milestone Mar 3, 2014
@vieux
Copy link
Contributor

vieux commented Mar 3, 2014

LGTM

vieux added a commit that referenced this pull request Mar 3, 2014
fix(api): serve until the "acceptconnections" job
@vieux vieux merged commit 690fb50 into moby:master Mar 3, 2014
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