You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
docker-compose restart ought to exit with non-zero if it didn't actually restart #1236
If you have no containers running and you do docker-compose restart it exits with 0. It failed to restart so it should exit with non-zero. This will let you do something like:
I think it makes sense for restart, start, pause, and unpause.
I think kill, stop and rm don't need to error because the desired state is reached. If you run rm and there is nothing to remove, I wouldn't consider that an error (same idea with kill and stop)
There is a small issue with start though: In a few places in the test suite we have code where we call project.start() on a freshly created project and then explicitly test for containers count to be 0.
I have no idea why these tests are calling project.start(). I think we should remove it, but I also don't think it needs to be done for this change. I would think the warning would be implemented as part of the compose/cli/main.py module instead of in project, since it's more of a concern for the cli.
Right now project.start(), etc return nothing. I think we could have these methods return a list of containers they started, restarted, etc (or at least a count). Then the cli layer can print the warning and exit with the right status code (or maybe just raise an exception and let the existing exception handled do that).
@dnephin Thanks. Did it this way and submitted a PR. No impact on the tests (except adding a few more to test the new behaviour).
Please let me know if something doesn't quite look right.
Thanks.
Activity
seguins commentedon Nov 10, 2015
#44 says start / stop should be more verbose, maybe we can have the same things for start, stop, restart :
And what about pause, unpause, kill ? Should we have the same behavior ?
dbonev commentedon Dec 12, 2015
I can do that.
In terms of error message, I was thinking something along the lines of:
The same behaviour could work for stop, pause, unpause.
I'm not quite sure it's the right thing to do in the case of kill and rm though, as that would break lots of test because
is part of tearDown() and that would make lots of tests fail.
dnephin commentedon Dec 14, 2015
I think it makes sense for restart, start, pause, and unpause.
I think
kill,stopandrmdon't need to error because the desired state is reached. If you runrmand there is nothing to remove, I wouldn't consider that an error (same idea withkillandstop)dbonev commentedon Dec 15, 2015
Thanks. It makes sense.
There is a small issue with
startthough: In a few places in the test suite we have code where we callproject.start()on a freshly created project and then explicitly test for containers count to be 0.Something like this (lines 220 / 221) (taken directly from https://github.com/docker/compose/blob/master/tests/integration/project_test.py#L220).
Should we:
a) fix the tests (I count 13 such places) to not call
project.start()if nothing to start;b) leave
startwith the current behaviour;Thanks
dnephin commentedon Dec 15, 2015
I have no idea why these tests are calling
project.start(). I think we should remove it, but I also don't think it needs to be done for this change. I would think the warning would be implemented as part of thecompose/cli/main.pymodule instead of in project, since it's more of a concern for the cli.Right now
project.start(), etc return nothing. I think we could have these methods return a list of containers they started, restarted, etc (or at least a count). Then the cli layer can print the warning and exit with the right status code (or maybe just raise an exception and let the existing exception handled do that).dbonev commentedon Dec 15, 2015
@dnephin Thanks. Did it this way and submitted a PR. No impact on the tests (except adding a few more to test the new behaviour).
Please let me know if something doesn't quite look right.
Thanks.
Update common Prometheus files (docker#1236)