summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Buckley <timothy.jas.buckley@hpe.com>2016-03-03 20:14:26 -0700
committerTim Buckley <timothy.jas.buckley@hpe.com>2016-03-09 12:46:17 -0700
commit3663cc2be0a8469b197c9571607294e46d3d8db3 (patch)
treea63293ce871a7d1f1cac0629d5107a61fa498f7b
parente12fc216edf468b8a17e3cbddf26978d11cc8bc7 (diff)
Fix log_url parsing for new job types
Previously, the log_dir was determined by taking the dirname() of the log_url twice, which works when all collected 'testrepository.subunit' files were located under 'logs/'. Now that the worker is collecting subunit files from all jobs, this assumption can result in the Zuul UUID being cut off from the generated log_dir. This change adds a check to make sure path segments are only removed when the log_dir is 'logs/' or 'logs/old/'. Change-Id: I75c53c498261e44989cdb7bf49d909ebde2b2699
Notes
Notes (review): Code-Review+2: yolanda.robla <yolanda.robla-mota@hpe.com> Code-Review+1: Masayuki Igawa <masayuki.igawa@gmail.com> Code-Review+1: Matthew Treinish <mtreinish@kortar.org> Code-Review+1: Ricardo Carrillo Cruz <ricardo.carrillo.cruz@gmail.com> Code-Review+2: Jeremy Stanley <fungi@yuggoth.org> Workflow+1: Jeremy Stanley <fungi@yuggoth.org> Verified+2: Jenkins Submitted-by: Jenkins Submitted-at: Fri, 08 Apr 2016 18:21:24 +0000 Reviewed-on: https://review.openstack.org/288234 Project: openstack-infra/puppet-subunit2sql Branch: refs/heads/master
-rw-r--r--files/subunit-gearman-worker.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/files/subunit-gearman-worker.py b/files/subunit-gearman-worker.py
index 5780f8d..56ec4b3 100644
--- a/files/subunit-gearman-worker.py
+++ b/files/subunit-gearman-worker.py
@@ -180,7 +180,17 @@ class Subunit2SQLProcessor(object):
180 # Set run metadata from gearman 180 # Set run metadata from gearman
181 log_url = subunit.pop('log_url', None) 181 log_url = subunit.pop('log_url', None)
182 if log_url: 182 if log_url:
183 log_dir = os.path.dirname(os.path.dirname(log_url)) 183 log_dir = os.path.dirname(log_url)
184
185 # log_dir should be the top-level directory containing a job run,
186 # but the subunit file may be nested in 0 - 2 subdirectories (top,
187 # logs/, or logs/old/), so we need to safely correct the path here
188 log_base = os.path.basename(log_dir)
189 if log_base == 'logs':
190 log_dir = os.path.dirname(log_dir)
191 elif log_base == 'old':
192 log_dir = os.path.dirname(os.path.dirname(log_dir))
193
184 shell.CONF.set_override('artifacts', log_dir) 194 shell.CONF.set_override('artifacts', log_dir)
185 shell.CONF.set_override('run_meta', subunit) 195 shell.CONF.set_override('run_meta', subunit)
186 # Parse subunit stream and store in DB 196 # Parse subunit stream and store in DB