diff --git a/src/build_workflow/build_args.py b/src/build_workflow/build_args.py index 253f4b8690..af096edf68 100644 --- a/src/build_workflow/build_args.py +++ b/src/build_workflow/build_args.py @@ -26,6 +26,7 @@ class BuildArgs: platform: str architecture: str distribution: str + continue_on_error: bool def __init__(self) -> None: parser = argparse.ArgumentParser(description="Build an OpenSearch Distribution") @@ -95,6 +96,13 @@ def __init__(self) -> None: default="tar", dest="distribution" ) + parser.add_argument( + "--continue-on-error", + dest="continue_on_error", + default=False, + action="store_true", + help="Do not fail the distribution build on any plugin component failure.", + ) args = parser.parse_args() self.logging_level = args.logging_level @@ -107,6 +115,7 @@ def __init__(self) -> None: self.architecture = args.architecture self.distribution = args.distribution self.script_path = sys.argv[0].replace("/src/run_build.py", "/build.sh") + self.continue_on_error = args.continue_on_error def component_command(self, name: str) -> str: return " ".join( diff --git a/src/run_build.py b/src/run_build.py index 8ca9af7ec4..8d169682d3 100755 --- a/src/run_build.py +++ b/src/run_build.py @@ -24,6 +24,7 @@ def main() -> int: args = BuildArgs() console.configure(level=args.logging_level) manifest = InputManifest.from_file(args.manifest) + failed_plugins = [] if args.ref_manifest: manifest = manifest.stable() @@ -70,10 +71,14 @@ def main() -> int: logging.info(f"Successfully built {component.name}") except: logging.error(f"Error building {component.name}, retry with: {args.component_command(component.name)}") - raise + if args.continue_on_error and component.name not in ['OpenSearch', 'OpenSearch Dashboards']: + failed_plugins.append(component.name) + continue + else: + raise build_recorder.write_manifest() - + logging.info(f"Failed plugins are {failed_plugins}") logging.info("Done.") return 0 diff --git a/tests/tests_build_workflow/test_build_args.py b/tests/tests_build_workflow/test_build_args.py index 9f85873af6..76e2956168 100644 --- a/tests/tests_build_workflow/test_build_args.py +++ b/tests/tests_build_workflow/test_build_args.py @@ -44,6 +44,14 @@ def test_keep_default(self) -> None: def test_keep_true(self) -> None: self.assertTrue(BuildArgs().keep) + @patch("argparse._sys.argv", [BUILD_PY, OPENSEARCH_MANIFEST]) + def test_continue_on_error_default(self) -> None: + self.assertFalse(BuildArgs().continue_on_error) + + @patch("argparse._sys.argv", [BUILD_PY, OPENSEARCH_MANIFEST, "--continue-on-error"]) + def test_continue_on_error_true(self) -> None: + self.assertTrue(BuildArgs().continue_on_error) + @patch("argparse._sys.argv", [BUILD_PY, OPENSEARCH_MANIFEST]) def test_snapshot_default(self) -> None: self.assertFalse(BuildArgs().snapshot)