-
Notifications
You must be signed in to change notification settings - Fork 712
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
Shutdown behavior #503
Shutdown behavior #503
Conversation
7ca50bf
to
85edcf0
Compare
if dockerReporter != nil { | ||
reporters = append(reporters, dockerReporter) | ||
} | ||
if dockerRegistry != nil { |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Tests I've done:
As it looks like the only way to gracefully shutdown runsvdir is with sighup, we need to make ./scope stop send sighup for docker stop: diff --git a/scope b/scope
index a973f23..9a724c6 100755
--- a/scope
+++ b/scope
@@ -189,7 +189,7 @@ case "$COMMAND" in
stop)
[ $# -eq 0 ] || usage
- if ! docker stop $SCOPE_CONTAINER_NAME >/dev/null 2>&1 ; then
+ if ! docker kill -s HUP $SCOPE_CONTAINER_NAME >/dev/null 2>&1 ; then
echo "Weave Scope is not running." >&2
fi
docker rm -f $SCOPE_CONTAINER_NAME >/dev/null 2>&1 || true |
@@ -32,20 +32,19 @@ func main() { | |||
return | |||
} | |||
|
|||
defer log.Print("bye!") |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
I think its probably time we broke the probe main() function up into smaller pieces; perhaps have a probe struct to contain the reporters, taggers & tickers, make add{Reporter, Probe}, loop() and quit() functions on that? |
I prototyped that first, and this was cleaner. |
I will add this patch to the PR, thanks. |
Also need to consider how we add a test to ensure we never break this On Tue, Sep 22, 2015 at 3:46 PM, Peter Bourgon [email protected]
|
Test added; Note when I run it locally I don't see the app or probe shutdown cleanly, so I'm expecting the test to fail. |
So, LGTM? |
I fixed the test - it fails now (probe doesn't exit cleanly). |
d32f449
to
62d7935
Compare
Update. Good news: Other Docker+runit solutions appear to solve this with their own init script, which explicitly waits for services to exit before returning. I guess that can work, though it feels stupid to wrap a supervisor with a supervisor. Still researching... |
fce83dc
to
1a44e39
Compare
This definitely works, now:
@tomwilkie any ideas here? |
I'll take a look at the test tomorrow to see why its failing. |
Hmm when I run it, it works:
|
Test fixed. I'm blown away by the signal handling in the entrypoint.sh script, and I'm concerned we're leaving ourselves open to bugs like this https://blog.phusion.nl/2015/01/20/docker-and-the-pid-1-zombie-reaping-problem/ (which is why we we're exec'ing runit to begin with). Lets get this change in (so LGTM from me) and then give it some more thought. Perhaps a different supervisor? Perhaps we should merge the app and probe into a single process? That would remove a bunch of code and problems - and we could do it by effectively leaving them as completely separate, but just run in the same process? |
You're right. We should do it properly. I wouldn't like to switch to another supervisor. I would propose we adopt the phusion my_init script. What do you think? edit: it was observed that my_init depends on python3, which we'd like to avoid. Whipping up a quick equivalent to entrypoint.sh in Go, which does proper reaping. |
e3f7144
to
fcd521e
Compare
@tomwilkie Is this acceptable to you? See peterbourgon/runsvinit. |
fcd521e
to
f09b7fb
Compare
Also, needs a rebase so we can see how this has affected coverage. I've got a feeling its going to have gone down, as probe/main.go is basically untested. |
OK, will add.
OK, will change.
I'll add CI. I'm ambivalent on moving it to Weaveworks; it has nothing to do with our core mission. Once I add the reaping tests, I'll ask you to review it.
OK, will rebase. |
f09b7fb
to
52b9777
Compare
@@ -17,6 +17,8 @@ SCOPE_VERSION=$(shell git rev-parse --short HEAD) | |||
DOCKER_VERSION=1.3.1 | |||
DOCKER_DISTRIB=docker/docker-$(DOCKER_VERSION).tgz | |||
DOCKER_DISTRIB_URL=https://get.docker.com/builds/Linux/x86_64/docker-$(DOCKER_VERSION).tgz | |||
RUNSVINIT=docker/runsvinit | |||
RUNSVINIT_TGZ=docker/runsvinit-linux-amd64.tgz |
This comment was marked as abuse.
This comment was marked as abuse.
Sorry, something went wrong.
Some minor comments. Should also squash this down to 1 changeset. And I think you should get someone like @dpw to review the supervisor. Other than that, LGTM. |
- Restructure main funcs for clean defer-stack-unwinds - Fix Docker container to handle signals properly - Introduce runsvinit for container init process - Integration test
39a955c
to
36b743f
Compare
Resolves #424.