api: sysroot: detect and handle artifact failures
BUG=b:255838545
TEST=run_tests
Change-Id: I11b9f366456fa2c78f4b113babd653735052e228
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3988684
Reviewed-by: Alex Klein <saklein@chromium.org>
Tested-by: Jack Neus <jackneus@google.com>
Commit-Queue: Jack Neus <jackneus@google.com>
Reviewed-by: Madeleine Hardt <hardtmad@google.com>
diff --git a/api/controller/sysroot.py b/api/controller/sysroot.py
index 7235b19..b8a3369 100644
--- a/api/controller/sysroot.py
+++ b/api/controller/sysroot.py
@@ -6,6 +6,7 @@
import logging
import os
+import traceback
from chromite.api import controller
from chromite.api import faux
@@ -125,7 +126,30 @@
for output_artifact in in_proto.output_artifacts:
for artifact_type, func in artifact_types.items():
if artifact_type in output_artifact.artifact_types:
- result = func(chroot, sysroot_class, build_target, output_dir)
+ try:
+ result = func(
+ chroot, sysroot_class, build_target, output_dir
+ )
+ except Exception as e:
+ generated.append(
+ {
+ "type": artifact_type,
+ "failed": True,
+ "failure_reason": str(e),
+ }
+ )
+ artifact_name = (
+ common_pb2.ArtifactsByService.Sysroot.ArtifactType.Name(
+ artifact_type
+ )
+ )
+ logging.warning(
+ "%s artifact generation failed with exception %s",
+ artifact_name,
+ e,
+ )
+ logging.warning("traceback:\n%s", traceback.format_exc())
+ continue
if result:
generated.append(
{