mirror of https://github.com/docker/compose.git
Properly relay errors in execute_convergence_plan
Signed-off-by: Joffrey F <joffrey@docker.com>
This commit is contained in:
parent
c8a7891cc8
commit
457c16a7b1
|
@ -377,12 +377,16 @@ class Service(object):
|
||||||
self.start_container(container)
|
self.start_container(container)
|
||||||
return container
|
return container
|
||||||
|
|
||||||
return parallel_execute(
|
containers, errors = parallel_execute(
|
||||||
range(i, i + scale),
|
range(i, i + scale),
|
||||||
lambda n: create_and_start(self, n),
|
lambda n: create_and_start(self, n),
|
||||||
lambda n: self.get_container_name(n),
|
lambda n: self.get_container_name(n),
|
||||||
"Creating"
|
"Creating"
|
||||||
)[0]
|
)
|
||||||
|
if errors:
|
||||||
|
raise OperationFailedError(errors.values()[0])
|
||||||
|
|
||||||
|
return containers
|
||||||
|
|
||||||
def _execute_convergence_recreate(self, containers, scale, timeout, detached, start):
|
def _execute_convergence_recreate(self, containers, scale, timeout, detached, start):
|
||||||
if len(containers) > scale:
|
if len(containers) > scale:
|
||||||
|
@ -394,12 +398,14 @@ class Service(object):
|
||||||
container, timeout=timeout, attach_logs=not detached,
|
container, timeout=timeout, attach_logs=not detached,
|
||||||
start_new_container=start
|
start_new_container=start
|
||||||
)
|
)
|
||||||
containers = parallel_execute(
|
containers, errors = parallel_execute(
|
||||||
containers,
|
containers,
|
||||||
recreate,
|
recreate,
|
||||||
lambda c: c.name,
|
lambda c: c.name,
|
||||||
"Recreating"
|
"Recreating"
|
||||||
)[0]
|
)
|
||||||
|
if errors:
|
||||||
|
raise OperationFailedError(errors.values()[0])
|
||||||
if len(containers) < scale:
|
if len(containers) < scale:
|
||||||
containers.extend(self._execute_convergence_create(
|
containers.extend(self._execute_convergence_create(
|
||||||
scale - len(containers), detached, start
|
scale - len(containers), detached, start
|
||||||
|
@ -411,12 +417,16 @@ class Service(object):
|
||||||
self._downscale(containers[scale:], timeout)
|
self._downscale(containers[scale:], timeout)
|
||||||
containers = containers[:scale]
|
containers = containers[:scale]
|
||||||
if start:
|
if start:
|
||||||
parallel_execute(
|
_, errors = parallel_execute(
|
||||||
containers,
|
containers,
|
||||||
lambda c: self.start_container_if_stopped(c, attach_logs=not detached),
|
lambda c: self.start_container_if_stopped(c, attach_logs=not detached),
|
||||||
lambda c: c.name,
|
lambda c: c.name,
|
||||||
"Starting"
|
"Starting"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if errors:
|
||||||
|
raise OperationFailedError(errors.values()[0])
|
||||||
|
|
||||||
if len(containers) < scale:
|
if len(containers) < scale:
|
||||||
containers.extend(self._execute_convergence_create(
|
containers.extend(self._execute_convergence_create(
|
||||||
scale - len(containers), detached, start
|
scale - len(containers), detached, start
|
||||||
|
|
|
@ -151,7 +151,7 @@ class CLITestCase(DockerClientTestCase):
|
||||||
def test_help(self):
|
def test_help(self):
|
||||||
self.base_dir = 'tests/fixtures/no-composefile'
|
self.base_dir = 'tests/fixtures/no-composefile'
|
||||||
result = self.dispatch(['help', 'up'], returncode=0)
|
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
|
# Prevent tearDown from trying to create a project
|
||||||
self.base_dir = None
|
self.base_dir = None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue