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

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 327312aec7b1e4c65d42e2b1f85f59c28e44bd60
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:more-aggressive-snap-file-pruner
Merge into: launchpad:master
Diff against target: 58 lines (+9/-9)
2 files modified
lib/lp/scripts/garbo.py (+1/-1)
lib/lp/scripts/tests/test_garbo.py (+8/-8)
Reviewer Review Type Date Requested Status
Ioana Lasc (community) Approve
Review via email: mp+401203@code.launchpad.net

Commit message

Reduce SnapFilePruner threshold to 7 days

Description of the change

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.

To post a comment you must log in.
Revision history for this message
Ioana Lasc (ilasc) wrote :

LGTM

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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):
1510 AND Job.status = %s1510 AND Job.status = %s
1511 AND Job.date_finished <1511 AND Job.date_finished <
1512 CURRENT_TIMESTAMP AT TIME ZONE 'UTC'1512 CURRENT_TIMESTAMP AT TIME ZONE 'UTC'
1513 - CAST('30 days' AS INTERVAL)1513 - CAST('7 days' AS INTERVAL)
1514 AND SnapFile.libraryfile = LibraryFileAlias.id1514 AND SnapFile.libraryfile = LibraryFileAlias.id
1515 AND LibraryFileAlias.filename LIKE '%%.snap'1515 AND LibraryFileAlias.filename LIKE '%%.snap'
1516 """ % (SnapBuildJobType.STORE_UPLOAD.value, JobStatus.COMPLETED.value)1516 """ % (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):
1705 self.assertEqual(expected_count, store.find(SnapFile).count())1705 self.assertEqual(expected_count, store.find(SnapFile).count())
17061706
1707 def test_SnapFilePruner_old_snap_files(self):1707 def test_SnapFilePruner_old_snap_files(self):
1708 # Snap files attached to builds over 30 days old that have been1708 # Snap files attached to builds over 7 days old that have been
1709 # uploaded to the store are pruned.1709 # uploaded to the store are pruned.
1710 self._test_SnapFilePruner('foo.snap', JobStatus.COMPLETED, 30)1710 self._test_SnapFilePruner('foo.snap', JobStatus.COMPLETED, 7)
17111711
1712 def test_SnapFilePruner_old_non_snap_files(self):1712 def test_SnapFilePruner_old_non_snap_files(self):
1713 # Non-snap files attached to builds over 30 days old that have been1713 # Non-snap files attached to builds over 7 days old that have been
1714 # uploaded to the store are retained.1714 # uploaded to the store are retained.
1715 self._test_SnapFilePruner(1715 self._test_SnapFilePruner(
1716 'foo.tar.gz', JobStatus.COMPLETED, 30, expected_count=1)1716 'foo.tar.gz', JobStatus.COMPLETED, 7, expected_count=1)
17171717
1718 def test_SnapFilePruner_recent_binary_files(self):1718 def test_SnapFilePruner_recent_binary_files(self):
1719 # Snap binary files attached to builds less than 30 days old that1719 # Snap binary files attached to builds less than 7 days old that
1720 # have been uploaded to the store are retained.1720 # have been uploaded to the store are retained.
1721 self._test_SnapFilePruner(1721 self._test_SnapFilePruner(
1722 'foo.snap', JobStatus.COMPLETED, 29, expected_count=1)1722 'foo.snap', JobStatus.COMPLETED, 6, expected_count=1)
17231723
1724 def test_SnapFilePruner_binary_files_failed_to_upload(self):1724 def test_SnapFilePruner_binary_files_failed_to_upload(self):
1725 # Snap binary files attached to builds that failed to be uploaded to1725 # Snap binary files attached to builds that failed to be uploaded to
1726 # the store are retained.1726 # the store are retained.
1727 self._test_SnapFilePruner(1727 self._test_SnapFilePruner(
1728 'foo.snap', JobStatus.FAILED, 30, expected_count=1)1728 'foo.snap', JobStatus.FAILED, 7, expected_count=1)
17291729
1730 def test_SnapFilePruner_binary_files_no_upload_job(self):1730 def test_SnapFilePruner_binary_files_no_upload_job(self):
1731 # Snap binary files attached to builds with no store upload job are1731 # Snap binary files attached to builds with no store upload job are
1732 # retained.1732 # retained.
1733 self._test_SnapFilePruner('foo.snap', None, 30, expected_count=1)1733 self._test_SnapFilePruner('foo.snap', None, 7, expected_count=1)
17341734
17351735
1736class TestGarboTasks(TestCaseWithFactory):1736class TestGarboTasks(TestCaseWithFactory):

Subscribers

People subscribed via source and target branches

to status/vote changes: