From 9edc9021068a43f6eefec0632ba4f901231235d0 Mon Sep 17 00:00:00 2001 From: Justin Newberry Date: Thu, 25 Jan 2024 11:09:09 -0800 Subject: [PATCH] LogReader: fail-fast on invalid segments (#31152) * don't check all * is old-commit-hash: edd2428b6067381ffaa25420d6fd9f0f142038a8 --- tools/lib/logreader.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/lib/logreader.py b/tools/lib/logreader.py index 6c1174611b..d6c1cc90c2 100755 --- a/tools/lib/logreader.py +++ b/tools/lib/logreader.py @@ -161,12 +161,14 @@ def direct_source(file_or_url): return [file_or_url] def get_invalid_files(files): - return [f for f in files if f is None or not file_exists(f)] + for f in files: + if f is None or not file_exists(f): + yield f def check_source(source, *args): try: files = source(*args) - assert len(get_invalid_files(files)) == 0 + assert next(get_invalid_files(files), None) is None return True, files except Exception: return False, None @@ -177,7 +179,6 @@ def auto_source(*args): valid, ret = check_source(source, *args) if valid: return ret - return comma_api_source(*args) def parse_useradmin(identifier): @@ -256,7 +257,7 @@ class LogReader: def reset(self): self.logreader_identifiers = self._parse_identifiers(self.identifier) - invalid_count = len(get_invalid_files(self.logreader_identifiers)) + invalid_count = len(list(get_invalid_files(self.logreader_identifiers))) assert invalid_count == 0, f"{invalid_count}/{len(self.logreader_identifiers)} invalid log(s) found, please ensure all logs \ are uploaded or auto fallback to qlogs with '/a' selector at the end of the route name."