artifacts controller: Consider no-image-dir a success.
There are now builders that do not build images, but call the
image archive endpoints. Allow calling these endpoints
successfully without producing artifacts, i.e. it successfully
produced artifacts for all existing images.
BUG=chromium:1017880
TEST=run_tests
Change-Id: I07f182fd09b1a80a7b38b8250951d1fa00cf2cd0
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/1880271
Tested-by: Alex Klein <saklein@chromium.org>
Commit-Queue: Alex Klein <saklein@chromium.org>
Reviewed-by: Sean Abraham <seanabraham@chromium.org>
diff --git a/api/controller/artifacts.py b/api/controller/artifacts.py
index 8974ec5..3347bab 100644
--- a/api/controller/artifacts.py
+++ b/api/controller/artifacts.py
@@ -34,15 +34,14 @@
target (str): Name of the build target.
Returns:
- Path to the directory containing target images.
-
- Raises:
- DieSystemExit: If the image dir does not exist.
+ Path to the latest directory containing target images or None.
"""
image_dir = os.path.join(build_root, 'src/build/images', target, 'latest')
if not os.path.exists(image_dir):
- cros_build_lib.Die('Expected to find image output for target %s at %s, '
- 'but path does not exist' % (target, image_dir))
+ logging.warning('Expected to find image output for target %s at %s, but '
+ 'path does not exist', target, image_dir)
+ return None
+
return image_dir
@@ -55,6 +54,8 @@
build_target = controller_util.ParseBuildTarget(input_proto.build_target)
output_dir = input_proto.output_dir
image_dir = _GetImageDir(constants.SOURCE_ROOT, build_target.name)
+ if image_dir is None:
+ return
archives = artifacts.ArchiveImages(image_dir, output_dir)
@@ -77,6 +78,8 @@
target = input_proto.build_target.name
output_dir = input_proto.output_dir
image_dir = _GetImageDir(constants.SOURCE_ROOT, target)
+ if image_dir is None:
+ return None
archive = artifacts.BundleImageZip(output_dir, image_dir)
output_proto.artifacts.add().path = os.path.join(output_dir, archive)
@@ -100,6 +103,9 @@
# Use the first available image to create the update payload.
img_dir = _GetImageDir(build_root, target)
+ if img_dir is None:
+ return None
+
img_types = [constants.IMAGE_TYPE_TEST, constants.IMAGE_TYPE_DEV,
constants.IMAGE_TYPE_BASE]
img_names = [constants.IMAGE_TYPE_TO_NAME[t] for t in img_types]