From 835c27cac195b1b4feba872cec4d45c0d5259ca2 Mon Sep 17 00:00:00 2001 From: Kevin Carter Date: Fri, 15 May 2020 12:53:23 -0500 Subject: [PATCH] Enhance error messages when building containers This change will improve our error messaging when building containers by returning all exceptions when there's an issue. This will allow us to grok all known within a single log and handle errors based on the RC information. Change-Id: I855ad2ec3ae27f2c18d53f1d17e4c7041e2258a3 Signed-off-by: Kevin Carter (cherry picked from commit f7458220494687097967363f04f2e376b5aadb9a) --- tripleo_common/image/builder/buildah.py | 17 ++++++++++++++--- .../tests/image/builder/test_buildah.py | 2 +- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tripleo_common/image/builder/buildah.py b/tripleo_common/image/builder/buildah.py index f84caf661..f96920f82 100644 --- a/tripleo_common/image/builder/buildah.py +++ b/tripleo_common/image/builder/buildah.py @@ -205,12 +205,23 @@ class BuildahBuilder(base.BaseBuilder): # failed a SystemError will be raised using the # exception information. If any job was loaded # but not executed a SystemError will be raised. + exceptions = list() for job in done: if job._exception: - raise SystemError("%(container)s raised %(exception)s" % - {'container': future_to_build[job], - 'exception': job._exception}) + exceptions.append( + "\nException information: {exception}".format( + exception=job._exception + ) + ) else: + if exceptions: + raise RuntimeError( + '\nThe following errors were detected during ' + 'container build(s):\n{exceptions}'.format( + exceptions='\n'.join(exceptions) + ) + ) + if not_done: error_msg = ('The following jobs were ' 'incomplete: {}'.format( diff --git a/tripleo_common/tests/image/builder/test_buildah.py b/tripleo_common/tests/image/builder/test_buildah.py index f276313e1..c71eae731 100644 --- a/tripleo_common/tests/image/builder/test_buildah.py +++ b/tripleo_common/tests/image/builder/test_buildah.py @@ -185,7 +185,7 @@ class TestBuildahBuilder(base.TestCase): mock_submit.side_effect = R_FAILED_LIST _b = bb(WORK_DIR, DEPS) self.assertRaises( - SystemError, + RuntimeError, _b.build_all, deps=BUILD_ALL_LIST_CONTAINERS )