← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:more-aggressive-snap-file-pruner into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:more-aggressive-snap-file-pruner into launchpad:master.

Commit message:
Reduce SnapFilePruner threshold to 7 days

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/401203

The previous threshold of 30 days (since the snap store upload job completed) was probably a bit too conservative, and it looks as though reducing it to 7 days will save about a terabyte of librarian space.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:more-aggressive-snap-file-pruner into launchpad:master.
diff --git a/lib/lp/scripts/garbo.py b/lib/lp/scripts/garbo.py
index 0f4867a..4492911 100644
--- a/lib/lp/scripts/garbo.py
+++ b/lib/lp/scripts/garbo.py
@@ -1510,7 +1510,7 @@ class SnapFilePruner(BulkPruner):
             AND Job.status = %s
             AND Job.date_finished <
                 CURRENT_TIMESTAMP AT TIME ZONE 'UTC'
-                - CAST('30 days' AS INTERVAL)
+                - CAST('7 days' AS INTERVAL)
             AND SnapFile.libraryfile = LibraryFileAlias.id
             AND LibraryFileAlias.filename LIKE '%%.snap'
         """ % (SnapBuildJobType.STORE_UPLOAD.value, JobStatus.COMPLETED.value)
diff --git a/lib/lp/scripts/tests/test_garbo.py b/lib/lp/scripts/tests/test_garbo.py
index 2f1d71e..e7f7dca 100644
--- a/lib/lp/scripts/tests/test_garbo.py
+++ b/lib/lp/scripts/tests/test_garbo.py
@@ -1705,32 +1705,32 @@ class TestGarbo(FakeAdapterMixin, TestCaseWithFactory):
         self.assertEqual(expected_count, store.find(SnapFile).count())
 
     def test_SnapFilePruner_old_snap_files(self):
-        # Snap files attached to builds over 30 days old that have been
+        # Snap files attached to builds over 7 days old that have been
         # uploaded to the store are pruned.
-        self._test_SnapFilePruner('foo.snap', JobStatus.COMPLETED, 30)
+        self._test_SnapFilePruner('foo.snap', JobStatus.COMPLETED, 7)
 
     def test_SnapFilePruner_old_non_snap_files(self):
-        # Non-snap files attached to builds over 30 days old that have been
+        # Non-snap files attached to builds over 7 days old that have been
         # uploaded to the store are retained.
         self._test_SnapFilePruner(
-            'foo.tar.gz', JobStatus.COMPLETED, 30, expected_count=1)
+            'foo.tar.gz', JobStatus.COMPLETED, 7, expected_count=1)
 
     def test_SnapFilePruner_recent_binary_files(self):
-        # Snap binary files attached to builds less than 30 days old that
+        # Snap binary files attached to builds less than 7 days old that
         # have been uploaded to the store are retained.
         self._test_SnapFilePruner(
-            'foo.snap', JobStatus.COMPLETED, 29, expected_count=1)
+            'foo.snap', JobStatus.COMPLETED, 6, expected_count=1)
 
     def test_SnapFilePruner_binary_files_failed_to_upload(self):
         # Snap binary files attached to builds that failed to be uploaded to
         # the store are retained.
         self._test_SnapFilePruner(
-            'foo.snap', JobStatus.FAILED, 30, expected_count=1)
+            'foo.snap', JobStatus.FAILED, 7, expected_count=1)
 
     def test_SnapFilePruner_binary_files_no_upload_job(self):
         # Snap binary files attached to builds with no store upload job are
         # retained.
-        self._test_SnapFilePruner('foo.snap', None, 30, expected_count=1)
+        self._test_SnapFilePruner('foo.snap', None, 7, expected_count=1)
 
 
 class TestGarboTasks(TestCaseWithFactory):