Merge lp:~wgrant/launchpad/ppa-pub-skip into lp:launchpad

Proposed by William Grant
Status: Merged
Merged at revision: 16508
Proposed branch: lp:~wgrant/launchpad/ppa-pub-skip
Merge into: lp:launchpad
Diff against target: 180 lines (+34/-14)
6 files modified
lib/lp/archivepublisher/domination.py (+5/-2)
lib/lp/archivepublisher/publishing.py (+5/-8)
lib/lp/archivepublisher/tests/test_publisher.py (+4/-2)
lib/lp/registry/model/distribution.py (+4/-2)
lib/lp/soyuz/doc/distribution.txt (+15/-0)
lib/lp/soyuz/scripts/publishdistro.py (+1/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/ppa-pub-skip
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code Approve
Review via email: mp+150264@code.launchpad.net

Commit message

Fix a couple of issues causing deleted PPAs to get their directories recreated on disk.

Description of the change

Fix a couple of issues causing deleted PPAs to get their directories recreated on disk. One or the other fix is sufficient, but one is the sensible fix and the other has been bugging me for years.

 - Calling getPublisher creates the archive directory tree on disk. This is rather counterintuitive, since the returned Publisher object has methods for deleting the archive and other similar things. I moved it to a Publisher.setupArchiveDirs method that's called in the relevant places.

 - Distribution.getPendingPublicationPPAs assumed that a PPA had pending deletions as long as scheduleddeletiondate was unset, when in fact both scheduleddeletiondate and dateremoved need to be unset. It could be argued that scheduleddeletiondate should be set whenever dateremoved is, but sometimes (mostly PPA deletion) the deletion is executed immediately. This should also fix some performance issues in the PPA publisher.

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) wrote :

100 # 'getPublisher' is what actually configures the htaccess file.

That comment is now out of date. :-)

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/archivepublisher/domination.py'
--- lib/lp/archivepublisher/domination.py 2012-08-17 11:15:35 +0000
+++ lib/lp/archivepublisher/domination.py 2013-02-25 05:33:23 +0000
@@ -517,6 +517,7 @@
517 binarypackagepublishinghistory.distroarchseries =517 binarypackagepublishinghistory.distroarchseries =
518 distroarchseries.id AND518 distroarchseries.id AND
519 binarypackagepublishinghistory.scheduleddeletiondate IS NULL AND519 binarypackagepublishinghistory.scheduleddeletiondate IS NULL AND
520 binarypackagepublishinghistory.dateremoved IS NULL AND
520 binarypackagepublishinghistory.archive = %s AND521 binarypackagepublishinghistory.archive = %s AND
521 binarypackagebuild.source_package_release = %s AND522 binarypackagebuild.source_package_release = %s AND
522 distroarchseries.distroseries = %s AND523 distroarchseries.distroseries = %s AND
@@ -786,7 +787,8 @@
786 sourcepackagepublishinghistory.archive = %s AND787 sourcepackagepublishinghistory.archive = %s AND
787 sourcepackagepublishinghistory.pocket = %s AND788 sourcepackagepublishinghistory.pocket = %s AND
788 sourcepackagepublishinghistory.status IN %s AND789 sourcepackagepublishinghistory.status IN %s AND
789 sourcepackagepublishinghistory.scheduleddeletiondate is NULL790 sourcepackagepublishinghistory.scheduleddeletiondate is NULL AND
791 sourcepackagepublishinghistory.dateremoved is NULL
790 """ % sqlvalues(792 """ % sqlvalues(
791 distroseries, self.archive, pocket,793 distroseries, self.archive, pocket,
792 inactive_publishing_status))794 inactive_publishing_status))
@@ -798,7 +800,8 @@
798 binarypackagepublishinghistory.archive = %s AND800 binarypackagepublishinghistory.archive = %s AND
799 binarypackagepublishinghistory.pocket = %s AND801 binarypackagepublishinghistory.pocket = %s AND
800 binarypackagepublishinghistory.status IN %s AND802 binarypackagepublishinghistory.status IN %s AND
801 binarypackagepublishinghistory.scheduleddeletiondate is NULL803 binarypackagepublishinghistory.scheduleddeletiondate is NULL AND
804 binarypackagepublishinghistory.dateremoved is NULL
802 """ % sqlvalues(805 """ % sqlvalues(
803 distroseries, self.archive, pocket,806 distroseries, self.archive, pocket,
804 inactive_publishing_status),807 inactive_publishing_status),
805808
=== modified file 'lib/lp/archivepublisher/publishing.py'
--- lib/lp/archivepublisher/publishing.py 2013-02-20 04:02:11 +0000
+++ lib/lp/archivepublisher/publishing.py 2013-02-25 05:33:23 +0000
@@ -96,9 +96,6 @@
96 It ensures the given archive location matches the minimal structure96 It ensures the given archive location matches the minimal structure
97 required.97 required.
98 """98 """
99 log.debug("Making directories as needed.")
100 pubconf.setupArchiveDirs()
101
102 log.debug("Preparing on-disk pool representation.")99 log.debug("Preparing on-disk pool representation.")
103 dp = DiskPool(pubconf.poolroot, pubconf.temproot,100 dp = DiskPool(pubconf.poolroot, pubconf.temproot,
104 logging.getLogger("DiskPool"))101 logging.getLogger("DiskPool"))
@@ -145,8 +142,6 @@
145142
146 disk_pool = _getDiskPool(pubconf, log)143 disk_pool = _getDiskPool(pubconf, log)
147144
148 _setupHtaccess(archive, pubconf, log)
149
150 if distsroot is not None:145 if distsroot is not None:
151 log.debug("Overriding dists root with %s." % distsroot)146 log.debug("Overriding dists root with %s." % distsroot)
152 pubconf.distsroot = distsroot147 pubconf.distsroot = distsroot
@@ -197,9 +192,6 @@
197 self.archive = archive192 self.archive = archive
198 self.allowed_suites = allowed_suites193 self.allowed_suites = allowed_suites
199194
200 if not os.path.isdir(config.poolroot):
201 raise ValueError("Root %s is not a directory or does "
202 "not exist" % config.poolroot)
203 self._diskpool = diskpool195 self._diskpool = diskpool
204196
205 if library is None:197 if library is None:
@@ -217,6 +209,11 @@
217 # This is a set of tuples in the form (distroseries.name, pocket)209 # This is a set of tuples in the form (distroseries.name, pocket)
218 self.release_files_needed = set()210 self.release_files_needed = set()
219211
212 def setupArchiveDirs(self):
213 self.log.debug("Setting up archive directories.")
214 self._config.setupArchiveDirs()
215 _setupHtaccess(self.archive, self._config, self.log)
216
220 def isDirty(self, distroseries, pocket):217 def isDirty(self, distroseries, pocket):
221 """True if a publication has happened in this release and pocket."""218 """True if a publication has happened in this release and pocket."""
222 return (distroseries.name, pocket) in self.dirty_pockets219 return (distroseries.name, pocket) in self.dirty_pockets
223220
=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
--- lib/lp/archivepublisher/tests/test_publisher.py 2013-02-20 04:02:11 +0000
+++ lib/lp/archivepublisher/tests/test_publisher.py 2013-02-25 05:33:23 +0000
@@ -167,6 +167,7 @@
167 dead_bpph.supersede()167 dead_bpph.supersede()
168168
169 publisher = getPublisher(test_archive, None, self.logger)169 publisher = getPublisher(test_archive, None, self.logger)
170 publisher.setupArchiveDirs()
170171
171 self.assertTrue(os.path.exists(publisher._config.archiveroot))172 self.assertTrue(os.path.exists(publisher._config.archiveroot))
172173
@@ -212,6 +213,7 @@
212 purpose=ArchivePurpose.PPA)213 purpose=ArchivePurpose.PPA)
213 logger = BufferLogger()214 logger = BufferLogger()
214 publisher = getPublisher(test_archive, None, logger)215 publisher = getPublisher(test_archive, None, logger)
216 publisher.setupArchiveDirs()
215217
216 self.assertTrue(os.path.exists(publisher._config.archiveroot))218 self.assertTrue(os.path.exists(publisher._config.archiveroot))
217219
@@ -1133,8 +1135,8 @@
1133 ppa.buildd_secret = "geheim"1135 ppa.buildd_secret = "geheim"
11341136
1135 # Set up the publisher for it and publish its repository.1137 # Set up the publisher for it and publish its repository.
1136 # 'getPublisher' is what actually configures the htaccess file.1138 # setupArchiveDirs is what actually configures the htaccess file.
1137 getPublisher(ppa, [], self.logger)1139 getPublisher(ppa, [], self.logger).setupArchiveDirs()
1138 pubconf = getPubConfig(ppa)1140 pubconf = getPubConfig(ppa)
1139 htaccess_path = os.path.join(pubconf.htaccessroot, ".htaccess")1141 htaccess_path = os.path.join(pubconf.htaccessroot, ".htaccess")
1140 self.assertTrue(os.path.exists(htaccess_path))1142 self.assertTrue(os.path.exists(htaccess_path))
11411143
=== modified file 'lib/lp/registry/model/distribution.py'
--- lib/lp/registry/model/distribution.py 2013-02-06 09:15:36 +0000
+++ lib/lp/registry/model/distribution.py 2013-02-25 05:33:23 +0000
@@ -1275,7 +1275,8 @@
1275 Archive.purpose = %s AND1275 Archive.purpose = %s AND
1276 Archive.distribution = %s AND1276 Archive.distribution = %s AND
1277 SourcePackagePublishingHistory.archive = archive.id AND1277 SourcePackagePublishingHistory.archive = archive.id AND
1278 SourcePackagePublishingHistory.scheduleddeletiondate is null AND1278 SourcePackagePublishingHistory.scheduleddeletiondate IS NULL AND
1279 SourcePackagePublishingHistory.dateremoved IS NULL AND
1279 SourcePackagePublishingHistory.status IN (%s, %s)1280 SourcePackagePublishingHistory.status IN (%s, %s)
1280 """ % sqlvalues(ArchivePurpose.PPA, self,1281 """ % sqlvalues(ArchivePurpose.PPA, self,
1281 PackagePublishingStatus.PENDING,1282 PackagePublishingStatus.PENDING,
@@ -1289,7 +1290,8 @@
1289 Archive.purpose = %s AND1290 Archive.purpose = %s AND
1290 Archive.distribution = %s AND1291 Archive.distribution = %s AND
1291 BinaryPackagePublishingHistory.archive = archive.id AND1292 BinaryPackagePublishingHistory.archive = archive.id AND
1292 BinaryPackagePublishingHistory.scheduleddeletiondate is null AND1293 BinaryPackagePublishingHistory.scheduleddeletiondate IS NULL AND
1294 BinaryPackagePublishingHistory.dateremoved IS NULL AND
1293 BinaryPackagePublishingHistory.status IN (%s, %s)1295 BinaryPackagePublishingHistory.status IN (%s, %s)
1294 """ % sqlvalues(ArchivePurpose.PPA, self,1296 """ % sqlvalues(ArchivePurpose.PPA, self,
1295 PackagePublishingStatus.PENDING,1297 PackagePublishingStatus.PENDING,
12961298
=== modified file 'lib/lp/soyuz/doc/distribution.txt'
--- lib/lp/soyuz/doc/distribution.txt 2012-12-05 16:16:20 +0000
+++ lib/lp/soyuz/doc/distribution.txt 2013-02-25 05:33:23 +0000
@@ -236,11 +236,20 @@
236 >>> pending_ppa.id == cprov.archive.id236 >>> pending_ppa.id == cprov.archive.id
237 True237 True
238238
239If scheduleddeletiondate or dateremoved are set then the PPA is no
240longer pending. process-death-row will do the rest.
241
239 >>> login('mark@example.com')242 >>> login('mark@example.com')
240 >>> from lp.services.database.constants import UTC_NOW243 >>> from lp.services.database.constants import UTC_NOW
241 >>> src_pub.scheduleddeletiondate = UTC_NOW244 >>> src_pub.scheduleddeletiondate = UTC_NOW
242 >>> ubuntu.getPendingPublicationPPAs().count()245 >>> ubuntu.getPendingPublicationPPAs().count()
243 0246 0
247 >>> src_pub.scheduleddeletiondate = None
248 >>> ubuntu.getPendingPublicationPPAs().count()
249 1
250 >>> src_pub.dateremoved = UTC_NOW
251 >>> ubuntu.getPendingPublicationPPAs().count()
252 0
244253
245A binary pending publication also moves a PPA to the pending-publication254A binary pending publication also moves a PPA to the pending-publication
246state. In order to test this behaviour we will copy some binaries within255state. In order to test this behaviour we will copy some binaries within
@@ -285,6 +294,12 @@
285 >>> bin_pub.scheduleddeletiondate = UTC_NOW294 >>> bin_pub.scheduleddeletiondate = UTC_NOW
286 >>> ubuntu.getPendingPublicationPPAs().count()295 >>> ubuntu.getPendingPublicationPPAs().count()
287 0296 0
297 >>> bin_pub.scheduleddeletiondate = None
298 >>> ubuntu.getPendingPublicationPPAs().count()
299 1
300 >>> bin_pub.dateremoved = UTC_NOW
301 >>> ubuntu.getPendingPublicationPPAs().count()
302 0
288303
289304
290Distribution Archives305Distribution Archives
291306
=== modified file 'lib/lp/soyuz/scripts/publishdistro.py'
--- lib/lp/soyuz/scripts/publishdistro.py 2012-06-29 08:40:05 +0000
+++ lib/lp/soyuz/scripts/publishdistro.py 2013-02-25 05:33:23 +0000
@@ -300,6 +300,7 @@
300300
301 Commits transactions along the way.301 Commits transactions along the way.
302 """302 """
303 publisher.setupArchiveDirs()
303 publisher.A_publish(self.isCareful(self.options.careful_publishing))304 publisher.A_publish(self.isCareful(self.options.careful_publishing))
304 self.txn.commit()305 self.txn.commit()
305306