-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
[RFC] Revisit docker restart policy #1734
Comments
@josegonzalez mentioned "What happens on memory-constrained systems? Can you try this on a box with 512mb ram and 512mb swap?" in #1591 (comment) Let me see if I can get that running |
Using the --restart policy allows containers that have crashed/exited i.e. because of an application bug to be restarted by docker without a reboot of the server. Does #1613 provide that? |
oh yeah forgot about that 😄 |
Of course that would never happen to one of my apps 😉 |
I tried this on a new VirtualBox VM where after going through the above exercise top shows:
During the
But it came back down after the previous containers were killed. @josegonzalez what were you expecting from this exercise? |
My only concern is that this would potentially go haywire on systems with low amounts of memory. |
Do we want to add a restart policy by default when running containers? It would require docker 1.9.x. Or maybe alternatively, if we don't want to make docker 1.9.x a requirement, provide a application level Configuration option where a user can specify a default restart policy to be applied to new applications, that could default to no --restart docker option applied. |
@beverku We can make 1.9.x a requirement in 0.5.0. |
@josegonzalez, Yes that requirement would work for me. |
@michaelshobbs anything we need to worry about with re-enabling this? @beverku does this feature have an "analog" for configuration in heroku? |
@beverku want to make this change for us as a pr? |
I don't know, I don't actually use Heroku, but I'll poke around a bit and see if I can see it. I'll start working on a PR. It's going to be later in the week before I can start working on it though. |
What's the current best practice for auto-restarting crashed processes? Should I run that I've got an app in production that's getting its workers killed every once in a while, and I'm not sure the best course of action. |
@christiangenco thats probably what you want, though I don't know how that performs with server reboots. |
@josegonzalez Neat - I'll try it. Thank you! |
@christiangenco, that is exactly what I am doing now, until I can submit the PR referenced above. In my case it works perfectly with server reboot. |
@beverku The node I was testing it on just crashed my worker again without restarting it. Do I need to do more than |
@beverku what do you mean by "crashed my worker"? |
@josegonzalez My worker process (which is a sidekiq worker defined in my procfile) died and didn't restart, even though I ran I'm not sure how to check the logs to see why it crashed - this command:
just shows a gigantic stream of what looks like normal output. |
What is the output of:
|
It might be that |
@josegonzalez The output of It's entirely possible sidekiq killed itself without an exit code - I still can't track down why it's crashing. |
err sorry, not add. Drop that and run the command. |
$ dokku docker-options dbinbox
Deploy options:
--restart=unless-stopped
$ |
@christiangenco Saw your addition to #1878, did the |
This is probably going to have to wait until 0.6.0 because no one tested the conditions I wanted them to test :( |
@michaelshobbs Even with the docker-options set the worker processes still crash without resuming :/ |
Seems like your good to go, yea? |
@michaelshobbs seems like it so far! If all goes well I expect my d1 worker process to eventually die under heavy load but my d2 process to keep going. If that happens, I'll know that Thanks for your help! |
When using Furthermore, I think |
I'm sorry this completely fell off my radar, do you still want me to work on a PR or are you working on it @michaelshobbs ? I believe you have to pin to docker 1.9+ |
@beverku I do use Heroku. When an app crashes, it restarts it back, but if it crashes "too often" then is let crashed and mail if kept crashed for some time (hours, I guess). For "too often" I feel it like "5 times per minute or 10 per hour, whatever comes first", but had not to find it at the docs right now. This is a good compromise, as I don't want a broken container to be looped consuming bootup resources. |
@alanjds what you describe is closer to the on-failure[:max-retries] docker restart policy. But it seems like this is handled in a nice manner by docker in unless-stopped by: "An ever increasing delay (double the previous delay, starting at 100 milliseconds) is added before each restart to prevent flooding the server. This means the daemon will wait for 100 ms, then 200 ms, 400, 800, 1600, and so on until either the on-failure limit is hit, or when you docker stop or docker rm -f the container." see: https://docs.docker.com/engine/reference/run/#restart-policies-restart |
@beverku I'll put something together. should be a small change |
Ok thinking through this now. Given that we auto restore all apps on boot, I'm thinking the Thoughts on this? |
Sounds fine to me. We can make policies configurable in a future release. |
Nothing's crashed so far, and Strangely, I haven't changed any settings on |
Is there any method by which I can chain restarts? One app will crash if another is not running, etc. Has anyone handled this use case before? |
@paulwalker What do you mean, one app will crash if another is not running? |
@josegonzalez my app will exit with an error if it cannot successfully connect to another app running mongodb (configured via the dokku mongodb plugin). |
Can you hop on slack/irc so we can chat about this? I assume you're trying to test the above solution, correct? |
I haven't tested anything yet, just researching the proper way to have everything start up again after system reboot. submitted for invite on slack... |
I think the way to go here is to set a config var like
Valid restart policies would match the following bash regular expression:
If you unset that config variable - or if it did not yet exist - it would be reset to the initial default of Potential porcelain around the plumbing: # show the restart policy
dokku ps:restart-policy APP
# set the restart policy for a given application
dokku ps:restart-policy APP on-failure:10 @michaelshobbs thoughts? |
Applications without a restart-policy will have their policies set to `on-failure:10`. Users can completely unset the restart-policy using the `docker-options` plugin, though this will be equivalent to setting it explicitly to `no`. Restart policies must be explicitly set, and the following are all valid: - no - unless-stopped - always - on-failure - on-failure:NUMBER
Closing as there is a pull request (#2290) up. |
Applications without a restart-policy will have their policies set to `on-failure:10`. Users can completely unset the restart-policy using the `docker-options` plugin, though this will be equivalent to setting it explicitly to `no`. Restart policies must be explicitly set, and the following are all valid: - no - unless-stopped - always - on-failure - on-failure:NUMBER
RFC from @josegonzalez
I think the way to go here is to set a config var like
DOKKU_RESTART_POLICY
. This variable could contain the exact restart policy being applied to an application. An alternative is to use the docker-options plugin.Valid restart policies would match the following bash regular expression:
If you unset that config variable - or if it did not yet exist - it would be reset to the initial default of
on-failure:10
Removing the docker-options entry would simply remove all restart-policies. Restart policies would apply to all processes being managed.Potential porcelain around the plumbing:
Original post
Is it time to look into the restart policy again with docker 1.9.x out? Add a new unless-stopped restart policy (#15348) was added in 1.9.0
See:
#1591
#1505
Repasting my message from #1591 (comment) below:
OK, I was able to test out the
docker-option --restart=unless-stopped
. Based on the testing that I have performed this behaves as I would desire.Below is a summary of my testing:
I have a test-app deployed with DOKKU_SCALE=2
After setting the restart option following any reboot I would see the following behavior:
docker ps
shows 4 containers up.docker inspect
showed for both containers:After causing the app to crash (process.exit(1)) each container twice:
docker inspect
showed for both containers:Then
sudo reboot
Execute
dokku ps:restart test-app
3 Times in quick succession:docker ps
Shows 8 containers up for 1-2 minutesThen
sudo reboot
Then
dokku ps:stop test-app
docker ps
shows no containers runningThen
sudo reboot
ps:stop
and reboot with an app that does not have the restart policy.Push new version of the test-app
docker inspect
shows that the RestartPolicy is retained for both containers.Test crash the test-app
Then
sudo reboot
The text was updated successfully, but these errors were encountered: