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
1diff --git a/lib/lp/scripts/garbo.py b/lib/lp/scripts/garbo.py
2index 0f4867a..4492911 100644
3--- a/lib/lp/scripts/garbo.py
4+++ b/lib/lp/scripts/garbo.py
5@@ -1510,7 +1510,7 @@ class SnapFilePruner(BulkPruner):
6 AND Job.status = %s
7 AND Job.date_finished <
8 CURRENT_TIMESTAMP AT TIME ZONE 'UTC'
9- - CAST('30 days' AS INTERVAL)
10+ - CAST('7 days' AS INTERVAL)
11 AND SnapFile.libraryfile = LibraryFileAlias.id
12 AND LibraryFileAlias.filename LIKE '%%.snap'
13 """ % (SnapBuildJobType.STORE_UPLOAD.value, JobStatus.COMPLETED.value)
14diff --git a/lib/lp/scripts/tests/test_garbo.py b/lib/lp/scripts/tests/test_garbo.py
15index 2f1d71e..e7f7dca 100644
16--- a/lib/lp/scripts/tests/test_garbo.py
17+++ b/lib/lp/scripts/tests/test_garbo.py
18@@ -1705,32 +1705,32 @@ class TestGarbo(FakeAdapterMixin, TestCaseWithFactory):
19 self.assertEqual(expected_count, store.find(SnapFile).count())
20
21 def test_SnapFilePruner_old_snap_files(self):
22- # Snap files attached to builds over 30 days old that have been
23+ # Snap files attached to builds over 7 days old that have been
24 # uploaded to the store are pruned.
25- self._test_SnapFilePruner('foo.snap', JobStatus.COMPLETED, 30)
26+ self._test_SnapFilePruner('foo.snap', JobStatus.COMPLETED, 7)
27
28 def test_SnapFilePruner_old_non_snap_files(self):
29- # Non-snap files attached to builds over 30 days old that have been
30+ # Non-snap files attached to builds over 7 days old that have been
31 # uploaded to the store are retained.
32 self._test_SnapFilePruner(
33- 'foo.tar.gz', JobStatus.COMPLETED, 30, expected_count=1)
34+ 'foo.tar.gz', JobStatus.COMPLETED, 7, expected_count=1)
35
36 def test_SnapFilePruner_recent_binary_files(self):
37- # Snap binary files attached to builds less than 30 days old that
38+ # Snap binary files attached to builds less than 7 days old that
39 # have been uploaded to the store are retained.
40 self._test_SnapFilePruner(
41- 'foo.snap', JobStatus.COMPLETED, 29, expected_count=1)
42+ 'foo.snap', JobStatus.COMPLETED, 6, expected_count=1)
43
44 def test_SnapFilePruner_binary_files_failed_to_upload(self):
45 # Snap binary files attached to builds that failed to be uploaded to
46 # the store are retained.
47 self._test_SnapFilePruner(
48- 'foo.snap', JobStatus.FAILED, 30, expected_count=1)
49+ 'foo.snap', JobStatus.FAILED, 7, expected_count=1)
50
51 def test_SnapFilePruner_binary_files_no_upload_job(self):
52 # Snap binary files attached to builds with no store upload job are
53 # retained.
54- self._test_SnapFilePruner('foo.snap', None, 30, expected_count=1)
55+ self._test_SnapFilePruner('foo.snap', None, 7, expected_count=1)
56
57
58 class TestGarboTasks(TestCaseWithFactory):

Subscribers

People subscribed via source and target branches

to status/vote changes: