Skip to content

Commit

Permalink
Add changes to continue distribution build on plugin error
Browse files Browse the repository at this point in the history
Signed-off-by: Rishabh Singh <[email protected]>
  • Loading branch information
rishabh6788 committed Aug 2, 2023
1 parent 27f5ed0 commit f298230
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/build_workflow/build_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down
9 changes: 7 additions & 2 deletions src/run_build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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

Expand Down
8 changes: 8 additions & 0 deletions tests/tests_build_workflow/test_build_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit f298230

Please sign in to comment.