Properly relay errors in execute_convergence_plan

Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
Joffrey F 2017-04-18 12:53:43 -07:00
parent c8a7891cc8
commit 457c16a7b1
2 changed files with 16 additions and 6 deletions

View File

@ -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

View File

@ -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