Skip to content

Start, restart, pause and unpause exit with non-zero if nothing to do - #2550

Merged
aanand merged 1 commit into
docker:masterfrom
dbonev:1236-restart-to-exit-with-non-zero
Dec 16, 2015
Merged

aanand merged 1 commit into
docker:masterfrom
dbonev:1236-restart-to-exit-with-non-zero

Conversation

@dbonev

@dbonev dbonev commented Dec 15, 2015

Copy link
Copy Markdown

When there are no containers to restart (pause, unpause or start respectively), compose will now exit with non-zero status, printing an error message. This allows for usage like

docker-compose restart || docker-compose up

Fixes #1236

Signed-off-by: Dimitar Bonev [email protected]

Comment thread compose/cli/main.py Outdated

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Since this method doesn't use self, can we make it a module level function? There are a bunch of these at the bottom of the file.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I also wonder if it would be more correct to raise an exception here, to be handled by main() above, which already does a bunch of this kind of thing. That way we'd only have sys.exit() in a single function.

@dnephin

dnephin commented Dec 15, 2015

Copy link
Copy Markdown

Thanks for the PR!

I think this looks good, just a couple small requests.

I should also note that in the case where containers already exist in the desired state there won't be any errors, but I think that's correct behaviour.

@dnephin dnephin added this to the 1.6.0 milestone Dec 15, 2015
@dbonev
dbonev force-pushed the 1236-restart-to-exit-with-non-zero branch from 5912860 to bc843d6 Compare December 15, 2015 21:11
@dbonev

dbonev commented Dec 15, 2015

Copy link
Copy Markdown
Author

@dnephin Thanks for the feedback. Done both:

  • exit_if is now module-level and moved to the bottom of the file;
  • raising SystemExit instead of manually calling sys.exit

Thanks

@aanand

aanand commented Dec 16, 2015

Copy link
Copy Markdown

LGTM

1 similar comment
@dnephin

dnephin commented Dec 16, 2015

Copy link
Copy Markdown

LGTM

aanand added a commit that referenced this pull request Dec 16, 2015
Start, restart, pause and unpause exit with non-zero if nothing to do
@aanand
aanand merged commit c8f6330 into docker:master Dec 16, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants