From 457c16a7b1248ed177c5f9fa444c65f36329917e Mon Sep 17 00:00:00 2001 From: Joffrey F Date: Tue, 18 Apr 2017 12:53:43 -0700 Subject: [PATCH] Properly relay errors in execute_convergence_plan Signed-off-by: Joffrey F --- compose/service.py | 20 +++++++++++++++----- tests/acceptance/cli_test.py | 2 +- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/compose/service.py b/compose/service.py index 4fa3aeabf..65eded8ec 100644 --- a/compose/service.py +++ b/compose/service.py @@ -377,12 +377,16 @@ class Service(object): self.start_container(container) return container - return parallel_execute( + containers, errors = parallel_execute( range(i, i + scale), lambda n: create_and_start(self, n), lambda n: self.get_container_name(n), "Creating" - )[0] + ) + if errors: + raise OperationFailedError(errors.values()[0]) + + return containers def _execute_convergence_recreate(self, containers, scale, timeout, detached, start): if len(containers) > scale: @@ -394,12 +398,14 @@ class Service(object): container, timeout=timeout, attach_logs=not detached, start_new_container=start ) - containers = parallel_execute( + containers, errors = parallel_execute( containers, recreate, lambda c: c.name, "Recreating" - )[0] + ) + if errors: + raise OperationFailedError(errors.values()[0]) if len(containers) < scale: containers.extend(self._execute_convergence_create( scale - len(containers), detached, start @@ -411,12 +417,16 @@ class Service(object): self._downscale(containers[scale:], timeout) containers = containers[:scale] if start: - parallel_execute( + _, errors = parallel_execute( containers, lambda c: self.start_container_if_stopped(c, attach_logs=not detached), lambda c: c.name, "Starting" ) + + if errors: + raise OperationFailedError(errors.values()[0]) + if len(containers) < scale: containers.extend(self._execute_convergence_create( scale - len(containers), detached, start diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index 43dc216ba..c4b24b4b5 100644 --- a/tests/acceptance/cli_test.py +++ b/tests/acceptance/cli_test.py @@ -151,7 +151,7 @@ class CLITestCase(DockerClientTestCase): def test_help(self): self.base_dir = 'tests/fixtures/no-composefile' result = self.dispatch(['help', 'up'], returncode=0) - assert 'Usage: up [options] [SERVICE...]' in result.stdout + assert 'Usage: up [options] [--scale SERVICE=NUM...] [SERVICE...]' in result.stdout # Prevent tearDown from trying to create a project self.base_dir = None