From 390ba801a3299b1a73d31e739afb0992115a3901 Mon Sep 17 00:00:00 2001 From: aronahl Date: Wed, 9 Aug 2017 19:44:12 -0400 Subject: [PATCH] Fix exit code 0 upon parallel pull failure. Signed-off-by: Aaron Nall --- compose/project.py | 4 +++- tests/acceptance/cli_test.py | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/compose/project.py b/compose/project.py index 86fbda6ee..2310a2fcc 100644 --- a/compose/project.py +++ b/compose/project.py @@ -498,13 +498,15 @@ class Project(object): def pull_service(service): service.pull(ignore_pull_failures, True) - parallel.parallel_execute( + _, errors = parallel.parallel_execute( services, pull_service, operator.attrgetter('name'), 'Pulling', limit=5, ) + if len(errors): + raise ProjectError(b"\n".join(errors.values())) else: for service in services: service.pull(ignore_pull_failures, silent=silent) diff --git a/tests/acceptance/cli_test.py b/tests/acceptance/cli_test.py index bee7b74a2..78d1c1eb1 100644 --- a/tests/acceptance/cli_test.py +++ b/tests/acceptance/cli_test.py @@ -6,6 +6,7 @@ import datetime import json import os import os.path +import re import signal import subprocess import time @@ -448,6 +449,20 @@ class CLITestCase(DockerClientTestCase): assert self.dispatch(['pull', '--quiet']).stderr == '' assert self.dispatch(['pull', '--quiet']).stdout == '' + def test_pull_with_parallel_failure(self): + result = self.dispatch([ + '-f', 'ignore-pull-failures.yml', 'pull', '--parallel'], + returncode=1 + ) + + self.assertRegexpMatches(result.stderr, re.compile('^Pulling simple', re.MULTILINE)) + self.assertRegexpMatches(result.stderr, re.compile('^Pulling another', re.MULTILINE)) + self.assertRegexpMatches(result.stderr, + re.compile('^ERROR: for another .*does not exist.*', re.MULTILINE)) + self.assertRegexpMatches(result.stderr, + re.compile('''^(ERROR: )?(b')?.* nonexisting-image''', + re.MULTILINE)) + def test_build_plain(self): self.base_dir = 'tests/fixtures/simple-dockerfile' self.dispatch(['build', 'simple'])