launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #14908
[Merge] lp:~wgrant/launchpad/expire-some-p3as into lp:launchpad
William Grant has proposed merging lp:~wgrant/launchpad/expire-some-p3as into lp:launchpad.
Commit message:
Add a whitelist to expire_archive_files. Private PPAs can be made to expire.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~wgrant/launchpad/expire-some-p3as/+merge/142857
We have some very large private PPAs, which makes expire-archive-files' private-PPAs-never-expire rule somewhat problematic. This branch adds a whitelist of private PPAs to expire.
While the blacklist contains PPA owners, the whitelist contains specific PPAs. It's pretty awful, but there will be an explicit flag on the archive soon.
--
https://code.launchpad.net/~wgrant/launchpad/expire-some-p3as/+merge/142857
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~wgrant/launchpad/expire-some-p3as into lp:launchpad.
=== modified file 'lib/lp/soyuz/scripts/expire_archive_files.py'
--- lib/lp/soyuz/scripts/expire_archive_files.py 2013-01-07 02:40:55 +0000
+++ lib/lp/soyuz/scripts/expire_archive_files.py 2013-01-11 09:49:29 +0000
@@ -14,7 +14,7 @@
from lp.services.scripts.base import LaunchpadCronScript
from lp.soyuz.enums import ArchivePurpose
-# PPAs that we never want to expire.
+# PPA owners that we never want to expire.
BLACKLISTED_PPAS = """
adobe-isv
chelsea-team
@@ -34,6 +34,13 @@
bzr-nightly-ppa
""".split()
+# Particular PPAs (not owners, unlike the whitelist) that should be
+# expired even if they're private.
+WHITELISTED_PPAS = """
+landscape/lds-trunk
+kubuntu-ninjas/ppa
+""".split()
+
class ArchiveExpirer(LaunchpadCronScript):
"""Helper class for expiring old PPA binaries.
@@ -42,6 +49,7 @@
will be marked for immediate expiry.
"""
blacklist = BLACKLISTED_PPAS
+ whitelist = WHITELISTED_PPAS
def add_my_options(self):
"""Add script command line options."""
@@ -95,14 +103,16 @@
AND p.id = a.owner
AND (
(p.name IN %s AND a.purpose = %s)
- OR a.private IS TRUE
+ OR (a.private IS TRUE
+ AND (p.name || '/' || a.name) NOT IN %s)
OR a.purpose NOT IN %s
OR dateremoved >
CURRENT_TIMESTAMP AT TIME ZONE 'UTC' - interval %s
OR dateremoved IS NULL);
""" % sqlvalues(
stay_of_execution, archive_types, self.blacklist,
- ArchivePurpose.PPA, archive_types, stay_of_execution))
+ ArchivePurpose.PPA, self.whitelist, archive_types,
+ stay_of_execution))
lfa_ids = results.get_all()
return lfa_ids
@@ -148,7 +158,8 @@
AND p.id = a.owner
AND (
(p.name IN %(blacklist)s AND a.purpose = %(ppa)s)
- OR a.private IS TRUE
+ OR (a.private IS TRUE
+ AND (p.name || '/' || a.name) NOT IN %(whitelist)s)
OR a.purpose NOT IN %(archive_types)s
OR dateremoved > (
CURRENT_TIMESTAMP AT TIME ZONE 'UTC' -
@@ -158,6 +169,7 @@
stay_of_execution=stay_of_execution,
archive_types=archive_types,
blacklist=self.blacklist,
+ whitelist=self.whitelist,
ppa=ArchivePurpose.PPA))
lfa_ids = results.get_all()
=== modified file 'lib/lp/soyuz/scripts/tests/test_expire_archive_files.py'
--- lib/lp/soyuz/scripts/tests/test_expire_archive_files.py 2012-01-20 15:42:44 +0000
+++ lib/lp/soyuz/scripts/tests/test_expire_archive_files.py 2013-01-11 09:49:29 +0000
@@ -243,6 +243,17 @@
self.assertSourceNotExpired(source)
self.assertBinaryNotExpired(binary)
+ def testWhitelistingWorks(self):
+ """Test that whitelisted private PPAs are expired anyway."""
+ p3a = self.factory.makeArchive(private=True)
+ source, binary = self._setUpExpirablePublications(archive=p3a)
+ script = self.getScript()
+ script.whitelist = ['%s/%s' % (p3a.owner.name, p3a.name)]
+ switch_dbuser(self.dbuser)
+ script.main()
+ self.assertSourceExpired(source)
+ self.assertBinaryExpired(binary)
+
def testPrivatePPAsNotExpired(self):
"""Test that private PPAs are not expired."""
self.archive.private = True