api: Fix glob pattern for log files
Recent runs of CQ with failed emerge commands reveals that the package
name is available in the output proto, but the paths were not correctly
located. This CL edits the glob path to reflect the correct naming
scheme and emits a warning to build logs when no matching log files are
found.
BUG=b:204816060
TEST=unit
TEST=CQ forthcoming
TEST=ran gen_call_scripts after breaking net-wireless/floss locally.
Build log included the emitted warning before glob path was changed,
and now includes the log path in the output proto.
Change-Id: I0c29c4403c0f587ba9f5be2ef6de62555be935dd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/chromite/+/3336658
Tested-by: Lizzy Presland <zland@google.com>
Auto-Submit: Lizzy Presland <zland@google.com>
Reviewed-by: Alex Klein <saklein@chromium.org>
diff --git a/api/controller/sysroot.py b/api/controller/sysroot.py
index 0fa3c0f..b8a67fd 100644
--- a/api/controller/sysroot.py
+++ b/api/controller/sysroot.py
@@ -214,11 +214,13 @@
failed_pkg_data_msg = output_proto.failed_package_data.add()
controller_util.serialize_package_info(pkg_info, failed_pkg_data_msg.name)
glob_path = os.path.join(target_sysroot.portage_logdir,
- f'{pkg_info.category}:{pkg_info.package}:*.log')
+ f'{pkg_info.category}:{pkg_info.pvr}:*.log')
log_files = glob.glob(glob_path)
log_files.sort(reverse=True)
# Omit path if files don't exist for some reason
if not log_files:
+ logging.warning('Log file for %s was not found. Search path: %s',
+ pkg_info.cpvr, glob_path)
continue
failed_pkg_data_msg.log_path.path = log_files[0]
failed_pkg_data_msg.log_path.location = common_pb2.Path.INSIDE
@@ -301,11 +303,13 @@
failed_pkg_data_msg = output_proto.failed_package_data.add()
controller_util.serialize_package_info(pkg_info, failed_pkg_data_msg.name)
glob_path = os.path.join(target_sysroot.portage_logdir,
- f'{pkg_info.category}:{pkg_info.package}:*.log')
+ f'{pkg_info.category}:{pkg_info.pvr}:*.log')
log_files = glob.glob(glob_path)
log_files.sort(reverse=True)
# Omit path if files don't exist for some reason
if not log_files:
+ logging.warning('Log file for %s was not found. Search path: %s',
+ pkg_info.cpvr, glob_path)
continue
failed_pkg_data_msg.log_path.path = log_files[0]
failed_pkg_data_msg.log_path.location = common_pb2.Path.INSIDE