From 7fe1fcb6feb9a69fe62f242449f908bdc1c2f9a6 Mon Sep 17 00:00:00 2001 From: Sandon Van Ness Date: Mon, 18 Aug 2014 11:25:24 -0700 Subject: [PATCH] Speed up teuthology-kill. Read less information when its not needed for killing runs. Signed-off-by: Sandon Van Ness --- teuthology/kill.py | 2 +- teuthology/report.py | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/teuthology/kill.py b/teuthology/kill.py index 41f71ff86f..5a241356dd 100755 --- a/teuthology/kill.py +++ b/teuthology/kill.py @@ -92,7 +92,7 @@ def find_run_info(serializer, run_name): continue job_num += 1 beanstalk.print_progress(job_num, job_total, 'Reading Job: ') - job_info = serializer.job_info(run_name, job_id) + job_info = serializer.job_info(run_name, job_id, simple=True) for key in job_info.keys(): if key in run_info_fields and key not in run_info: run_info[key] = job_info[key] diff --git a/teuthology/report.py b/teuthology/report.py index 95ed0b34d2..ceaad59bfe 100644 --- a/teuthology/report.py +++ b/teuthology/report.py @@ -72,18 +72,24 @@ class ResultsSerializer(object): self.archive_base = archive_base or config.archive_base self.log = log or init_logging() - def job_info(self, run_name, job_id, pretty=False): + + def job_info(self, run_name, job_id, pretty=False, simple=False): """ Given a run name and job id, merge the job's YAML files together. :param run_name: The name of the run. :param job_id: The job's id. + :param simple(bool): Read less data for speed. :returns: A dict. """ job_archive_dir = os.path.join(self.archive_base, run_name, job_id) job_info = {} + + if simple: + self.yamls = ('orig.config.yaml', 'info.yaml') + for yaml_name in self.yamls: yaml_path = os.path.join(job_archive_dir, yaml_name) if not os.path.exists(yaml_path): @@ -93,14 +99,18 @@ class ResultsSerializer(object): if partial_info is not None: job_info.update(partial_info) + if 'job_id' not in job_info: + job_info['job_id'] = job_id + + if simple: + return job_info + log_path = os.path.join(job_archive_dir, 'teuthology.log') if os.path.exists(log_path): mtime = int(os.path.getmtime(log_path)) mtime_dt = datetime.fromtimestamp(mtime) job_info['updated'] = str(mtime_dt) - if 'job_id' not in job_info: - job_info['job_id'] = job_id return job_info -- 2.39.5