From 2f355836aedc9d55f0a3744b5b6cd1aa60bf275d Mon Sep 17 00:00:00 2001 From: Clark Boylan Date: Fri, 23 Aug 2019 13:35:59 -0700 Subject: [PATCH] Stop treating .gz files as special in log handling With our switch to swift hosted logs files ended in .gz are no longer equivalent to the filenames without the .gz. Swift expects us to be speific. For this reason normalize on using the actual file names as stored and reported rather than removing the suffix for human friendliness. Note we keep the .gz less tag value in the tags list. This is because e-r typically uses tags to identify files rather than pure paths or filenames. Change-Id: Ie9063f0ab35317357280690d9ad5e273025e3240 Related-Change: https://review.opendev.org/#/c/677236 --- .../library/submit_log_processor_jobs.py | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/roles/submit-log-processor-jobs/library/submit_log_processor_jobs.py b/roles/submit-log-processor-jobs/library/submit_log_processor_jobs.py index 4209366..f44f9d7 100644 --- a/roles/submit-log-processor-jobs/library/submit_log_processor_jobs.py +++ b/roles/submit-log-processor-jobs/library/submit_log_processor_jobs.py @@ -38,16 +38,7 @@ class FileMatcher(object): class File(object): def __init__(self, name, tags): - # Note that even if we upload a .gz we want to use the logical - # non compressed name for handling (it is easier on humans). - # The reason we can get away with this is that this name is used - # to construct the log_url below. The server serving that - # log_url treats foo.txt and foo.txt.gz as being the same content - # and serves both paths from the same backend content. - if name.endswith('.gz'): - self._name = name[:-3] - else: - self._name = name + self._name = name self._tags = tags @property @@ -128,8 +119,12 @@ class LogMatcher(object): def makeEvent(self, file_object): out_event = {} out_event["fields"] = self.makeFields(file_object.name) - out_event["tags"] = [os.path.basename(file_object.name)] + \ - file_object.tags + basename = os.path.basename(file_object.name) + out_event["tags"] = [basename] + file_object.tags + if basename.endswith(".gz"): + # Backward compat for e-r which relies on tag values + # without the .gx suffix + out_event["tags"].append(basename[:-3]) return out_event def makeFields(self, filename):