From a4dcf2b357ab8f9c5ecd12647e001ff750f96259 Mon Sep 17 00:00:00 2001 From: Zack Cerza Date: Fri, 1 Sep 2017 11:48:58 -0600 Subject: [PATCH] prune: Use summary.yaml to determine age of job If a job has been partially pruned, its directory's mtime will get bumped, causing total removal to be delayed by potentially months. Looking at the mtime of summary.yaml should provide results that are more intuitive. Signed-off-by: Zack Cerza --- teuthology/prune.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/teuthology/prune.py b/teuthology/prune.py index bbdcc4db67..cccd1d4c91 100644 --- a/teuthology/prune.py +++ b/teuthology/prune.py @@ -127,13 +127,13 @@ def maybe_remove_jobs(run_dir, pass_days, fail_days, dry_run=False): if PRESERVE_FILE in contents: return for child in contents: - item = os.path.join(run_dir, child) + job_path = os.path.join(run_dir, child) # Ensure the path isn't marked for preservation and that it is a # directory - if should_preserve(item) or not os.path.isdir(item): + if should_preserve(job_path) or not os.path.isdir(job_path): continue # Is it a job dir? - summary_path = os.path.join(item, 'summary.yaml') + summary_path = os.path.join(job_path, 'summary.yaml') if not os.path.exists(summary_path): continue # Depending on whether it passed or failed, we have a different age @@ -149,12 +149,12 @@ def maybe_remove_jobs(run_dir, pass_days, fail_days, dry_run=False): else: continue # Ensure the directory is old enough to remove - if not is_old_enough(item, days): + if not is_old_enough(summary_path, days): continue log.info("{job} is a {days}-day old {status} job; removing".format( - job=item, days=days, status=status)) + job=job_path, days=days, status=status)) if not dry_run: - remove(item) + remove(job_path) def maybe_remove_remotes(run_dir, days, dry_run=False): -- 2.39.5