]> git.apps.os.sepia.ceph.com Git - teuthology.git/commitdiff
prune: Use summary.yaml to determine age of job 1107/head
authorZack Cerza <zack@redhat.com>
Fri, 1 Sep 2017 17:48:58 +0000 (11:48 -0600)
committerZack Cerza <zack@redhat.com>
Fri, 1 Sep 2017 17:48:58 +0000 (11:48 -0600)
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 <zack@redhat.com>
teuthology/prune.py

index bbdcc4db6721dd1d43f16050637a3bcb4690e30b..cccd1d4c915a93ae4d0ceaf6d7903886a0537049 100644 (file)
@@ -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):