From db03937830a1d77f5fda0e44acc6570659662dd4 Mon Sep 17 00:00:00 2001 From: jQuery Dark theme project Date: Fri, 5 May 2023 03:22:46 +0530 Subject: [PATCH 1/6] issue #35 resolved - review required --- src/rocker/core.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/rocker/core.py b/src/rocker/core.py index 2f1a5353..d6829d0c 100644 --- a/src/rocker/core.py +++ b/src/rocker/core.py @@ -135,9 +135,11 @@ def get_docker_client(): def docker_build(docker_client = None, output_callback = None, **kwargs): image_id = None + build_success = False if not docker_client: docker_client = get_docker_client() + kwargs['decode'] = True for line in docker_client.build(**kwargs): output = line.get('stream', '').rstrip() @@ -150,12 +152,12 @@ def docker_build(docker_client = None, output_callback = None, **kwargs): match = re.match(r'Successfully built ([a-z0-9]{12})', output) if match: image_id = match.group(1) - - if image_id: + build_success = True + + if build_success: return image_id else: - print("no more output and success not detected") - return None + raise Exception("Build failed: no more output and success not detected") class SIGWINCHPassthrough(object): From 4db8835ab08a2c973ef5697f96e124bd36655042 Mon Sep 17 00:00:00 2001 From: jQuery Dark theme project Date: Fri, 5 May 2023 22:01:14 +0530 Subject: [PATCH 2/6] adding traceback for the error --- src/rocker/core.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/rocker/core.py b/src/rocker/core.py index d6829d0c..be3847b8 100644 --- a/src/rocker/core.py +++ b/src/rocker/core.py @@ -148,6 +148,9 @@ def docker_build(docker_client = None, output_callback = None, **kwargs): continue if output_callback is not None: output_callback(output) + + if "error" in output.lower(): + raise Exception(f"Build failed: {output}") match = re.match(r'Successfully built ([a-z0-9]{12})', output) if match: From 20dffb15082626ddd7df17ee412c80ed6f961e87 Mon Sep 17 00:00:00 2001 From: jQuery Dark theme project Date: Fri, 5 May 2023 22:11:28 +0530 Subject: [PATCH 3/6] adding traceback for the error --- src/rocker/core.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rocker/core.py b/src/rocker/core.py index be3847b8..6bd1e878 100644 --- a/src/rocker/core.py +++ b/src/rocker/core.py @@ -160,7 +160,7 @@ def docker_build(docker_client = None, output_callback = None, **kwargs): if build_success: return image_id else: - raise Exception("Build failed: no more output and success not detected") + raise Exception(f"Build failed: {output}") class SIGWINCHPassthrough(object): From ab116b44a113ab9bf6cc422a99603cc2e5c5de83 Mon Sep 17 00:00:00 2001 From: jQuery Dark theme project Date: Fri, 5 May 2023 22:25:51 +0530 Subject: [PATCH 4/6] adding traceback for the error --- src/rocker/core.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/rocker/core.py b/src/rocker/core.py index 6bd1e878..c6c27f3c 100644 --- a/src/rocker/core.py +++ b/src/rocker/core.py @@ -136,6 +136,7 @@ def get_docker_client(): def docker_build(docker_client = None, output_callback = None, **kwargs): image_id = None build_success = False + build_output = [] if not docker_client: docker_client = get_docker_client() @@ -148,9 +149,10 @@ def docker_build(docker_client = None, output_callback = None, **kwargs): continue if output_callback is not None: output_callback(output) + build_output.append(output) if "error" in output.lower(): - raise Exception(f"Build failed: {output}") + raise Exception("Build failed") match = re.match(r'Successfully built ([a-z0-9]{12})', output) if match: @@ -160,7 +162,7 @@ def docker_build(docker_client = None, output_callback = None, **kwargs): if build_success: return image_id else: - raise Exception(f"Build failed: {output}") + raise Exception("Build failed: "+"\n".join(build_output)) class SIGWINCHPassthrough(object): From 8cfe4a1c8e0e4f663ea0eea5b0115c1dd0ac1e95 Mon Sep 17 00:00:00 2001 From: jQuery Dark theme project Date: Fri, 5 May 2023 22:30:57 +0530 Subject: [PATCH 5/6] adding traceback for the error --- src/rocker/core.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/rocker/core.py b/src/rocker/core.py index c6c27f3c..515a601a 100644 --- a/src/rocker/core.py +++ b/src/rocker/core.py @@ -150,9 +150,6 @@ def docker_build(docker_client = None, output_callback = None, **kwargs): if output_callback is not None: output_callback(output) build_output.append(output) - - if "error" in output.lower(): - raise Exception("Build failed") match = re.match(r'Successfully built ([a-z0-9]{12})', output) if match: From 77a6d2c2e75d0d7a73319a8025b4aa51b8d22cb4 Mon Sep 17 00:00:00 2001 From: jQuery Dark theme project Date: Sat, 6 May 2023 16:40:05 +0530 Subject: [PATCH 6/6] resolving docker build issue --- src/rocker/core.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/rocker/core.py b/src/rocker/core.py index 515a601a..8eb7a264 100644 --- a/src/rocker/core.py +++ b/src/rocker/core.py @@ -136,7 +136,7 @@ def get_docker_client(): def docker_build(docker_client = None, output_callback = None, **kwargs): image_id = None build_success = False - build_output = [] + error_message = [] if not docker_client: docker_client = get_docker_client() @@ -149,17 +149,20 @@ def docker_build(docker_client = None, output_callback = None, **kwargs): continue if output_callback is not None: output_callback(output) - build_output.append(output) match = re.match(r'Successfully built ([a-z0-9]{12})', output) if match: image_id = match.group(1) build_success = True + elif "error" in output.lower(): + error_message.append(output) + if build_success: return image_id else: - raise Exception("Build failed: "+"\n".join(build_output)) + error_msg = "\n".join(error_message) + raise Exception(f"Build failed:\n{error_msg}") class SIGWINCHPassthrough(object):