mirror of
https://github.com/docker/compose.git
synced 2025-07-23 13:45:00 +02:00
Fix regression in handling of build errors
This commit is contained in:
parent
c78b952c3d
commit
3abce4259f
@ -52,7 +52,7 @@ def main():
|
|||||||
log.error(e.explanation)
|
log.error(e.explanation)
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
except BuildError as e:
|
except BuildError as e:
|
||||||
log.error("Service '%s' failed to build." % e.service.name)
|
log.error("Service '%s' failed to build: %s" % (e.service.name, e.reason))
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,8 +23,9 @@ DOCKER_CONFIG_HINTS = {
|
|||||||
|
|
||||||
|
|
||||||
class BuildError(Exception):
|
class BuildError(Exception):
|
||||||
def __init__(self, service):
|
def __init__(self, service, reason):
|
||||||
self.service = service
|
self.service = service
|
||||||
|
self.reason = reason
|
||||||
|
|
||||||
|
|
||||||
class CannotBeScaledError(Exception):
|
class CannotBeScaledError(Exception):
|
||||||
@ -307,7 +308,10 @@ class Service(object):
|
|||||||
stream=True
|
stream=True
|
||||||
)
|
)
|
||||||
|
|
||||||
all_events = stream_output(build_output, sys.stdout)
|
try:
|
||||||
|
all_events = stream_output(build_output, sys.stdout)
|
||||||
|
except StreamOutputError, e:
|
||||||
|
raise BuildError(self, unicode(e))
|
||||||
|
|
||||||
image_id = None
|
image_id = None
|
||||||
|
|
||||||
@ -338,6 +342,10 @@ class Service(object):
|
|||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
class StreamOutputError(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
def stream_output(output, stream):
|
def stream_output(output, stream):
|
||||||
is_terminal = hasattr(stream, 'fileno') and os.isatty(stream.fileno())
|
is_terminal = hasattr(stream, 'fileno') and os.isatty(stream.fileno())
|
||||||
all_events = []
|
all_events = []
|
||||||
@ -362,11 +370,7 @@ def stream_output(output, stream):
|
|||||||
# move cursor up `diff` rows
|
# move cursor up `diff` rows
|
||||||
stream.write("%c[%dA" % (27, diff))
|
stream.write("%c[%dA" % (27, diff))
|
||||||
|
|
||||||
try:
|
print_output_event(event, stream, is_terminal)
|
||||||
print_output_event(event, stream, is_terminal)
|
|
||||||
except Exception:
|
|
||||||
stream.write(repr(event) + "\n")
|
|
||||||
raise
|
|
||||||
|
|
||||||
if 'id' in event and is_terminal:
|
if 'id' in event and is_terminal:
|
||||||
# move cursor back down
|
# move cursor back down
|
||||||
@ -378,7 +382,7 @@ def stream_output(output, stream):
|
|||||||
|
|
||||||
def print_output_event(event, stream, is_terminal):
|
def print_output_event(event, stream, is_terminal):
|
||||||
if 'errorDetail' in event:
|
if 'errorDetail' in event:
|
||||||
raise Exception(event['errorDetail']['message'])
|
raise StreamOutputError(event['errorDetail']['message'])
|
||||||
|
|
||||||
terminator = ''
|
terminator = ''
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user