From 8b6e82437cad5abf4cf9775106f9f393e63660fe Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Thu, 10 Jul 2014 01:29:45 -0600 Subject: [PATCH] Tweak fetch_teuthology_branch() Specifically, make it match fetch_qa_suite()'s behavior. Signed-off-by: Zack Cerza --- teuthology/worker.py | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/teuthology/worker.py b/teuthology/worker.py index ca7ebc5b2d038..2dac400e6da97 100644 --- a/teuthology/worker.py +++ b/teuthology/worker.py @@ -70,10 +70,15 @@ class filelock(object): self.fd = None -def fetch_teuthology_branch(dest_path, branch='master'): +def fetch_teuthology_branch(branch): """ Make sure we have the correct teuthology branch checked out and up-to-date + + :param branch: The branche we want + :returns: The destination path """ + src_base_path = teuth_config.src_base_path + dest_path = os.path.join(src_base_path, 'teuthology_' + branch) # only let one worker create/update the checkout at a time lock = filelock('%s.lock' % dest_path) lock.acquire() @@ -101,6 +106,8 @@ def fetch_teuthology_branch(dest_path, branch='master'): finally: lock.release() + return dest_path + def fetch_qa_suite(branch): """ @@ -182,14 +189,9 @@ def main(ctx): teuthology_branch = job_config.get('teuthology_branch', 'master') job_config['teuthology_branch'] = teuthology_branch - teuth_path = os.path.join(os.getenv("HOME"), 'src', - 'teuthology_' + teuthology_branch) - try: - fetch_teuthology_branch(dest_path=teuth_path, - branch=teuthology_branch) + teuth_path = fetch_teuthology_branch(branch=teuthology_branch) suite_path = fetch_qa_suite(job_config['suite_branch']) - job_config['suite_path'] = suite_path except BranchNotFoundError: log.exception( "Branch not found; throwing job away") @@ -229,7 +231,7 @@ def main(ctx): log.info('Creating archive dir %s', archive_path_full) safepath.makedirs(ctx.archive_dir, safe_archive) log.info('Running job %d', job.jid) - run_job(job_config, teuth_bin_path) + run_job(job_config, teuth_bin_path, suite_path) job.delete() @@ -288,7 +290,7 @@ def run_with_watchdog(process, job_config): report.try_push_job_info(job_info, dict(status='dead')) -def run_job(job_config, teuth_bin_path): +def run_job(job_config, teuth_bin_path, suite_path): arg = [ os.path.join(teuth_bin_path, 'teuthology'), ] @@ -322,8 +324,7 @@ def run_job(job_config, teuth_bin_path): yaml.safe_dump(data=job_config, stream=tmp) tmp.flush() arg.append(tmp.name) - p = subprocess.Popen(args=arg, - environ=dict(PYTHONPATH=job_config['suite_path'])) + p = subprocess.Popen(args=arg, environ=dict(PYTHONPATH=suite_path)) log.info("Job archive: %s", job_config['archive_path']) log.info("Job PID: %s", str(p.pid)) -- 2.39.5