Merge lp:~cjwatson/launchpad/stop-publishing-obsolete-series into lp:launchpad

Proposed by Colin Watson
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 14622
Proposed branch: lp:~cjwatson/launchpad/stop-publishing-obsolete-series
Merge into: lp:launchpad
Diff against target: 98 lines (+63/-1)
2 files modified
lib/lp/archivepublisher/publishing.py (+23/-1)
lib/lp/archivepublisher/tests/test_publisher.py (+40/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/stop-publishing-obsolete-series
Reviewer Review Type Date Requested Status
Raphaël Badin (community) Approve
Review via email: mp+86967@code.launchpad.net

Commit message

[r=rvb][bug=905281] Skip publishing OBSOLETE and FUTURE series in PRIMARY and PARTNER archives.

Description of the change

== Summary ==

About 15 seconds of the primary archive publisher's runtime is spent considering obsolete distroseries. It's not a huge amount, but it would be nice to shave this off.

== Proposed fix ==

Exclude OBSOLETE and FUTURE series when publishing PRIMARY and PARTNER archives. The archive purpose restriction is because apparently OEM still has PPAs for obsolete series, as noted by William Grant pre-implementation.

== Tests ==

bin/test -vvct archivepublisher.tests.test_publisher.TestPublisher

== Demo and Q/A ==

Run the publisher on mawson. Given the current state of the dogfood database, the publisher log under "Step A: Publishing packages" should show it considering rusty, precise, oneiric, natty, maverick, lucid, newdog, hardy, testagain, and dozing, but not q-series, karmic, jaunty, intrepid, gutsy, feisty, edgy, dapper, breezy, hoary, or warty.

== lint ==

None.

To post a comment you must log in.
Revision history for this message
Raphaël Badin (rvb) wrote :

This looks good to land. Maybe you could merge testPublishingSkipsObsoletePrimarySeries and testPublishingSkipsFuturePrimarySeries into one single method to avoid code duplication.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/archivepublisher/publishing.py'
--- lib/lp/archivepublisher/publishing.py 2011-12-30 06:14:56 +0000
+++ lib/lp/archivepublisher/publishing.py 2012-01-03 01:07:25 +0000
@@ -39,6 +39,7 @@
39 RepositoryIndexFile,39 RepositoryIndexFile,
40 )40 )
41from lp.registry.interfaces.pocket import PackagePublishingPocket41from lp.registry.interfaces.pocket import PackagePublishingPocket
42from lp.registry.interfaces.series import SeriesStatus
42from lp.services.database.sqlbase import sqlvalues43from lp.services.database.sqlbase import sqlvalues
43from lp.services.librarian.client import LibrarianClient44from lp.services.librarian.client import LibrarianClient
44from lp.services.utils import file_exists45from lp.services.utils import file_exists
@@ -236,7 +237,28 @@
236 """237 """
237 self.log.debug("* Step A: Publishing packages")238 self.log.debug("* Step A: Publishing packages")
238239
239 for distroseries in self.distro.series:240 if self.archive.purpose in (
241 ArchivePurpose.PRIMARY,
242 ArchivePurpose.PARTNER,
243 ):
244 # For PRIMARY and PARTNER archives, skip OBSOLETE and FUTURE
245 # series. We will never want to publish anything in them, so it
246 # isn't worth thinking about whether they have pending
247 # publications.
248 consider_series = [
249 series
250 for series in self.distro.series
251 if series.status not in (
252 SeriesStatus.OBSOLETE,
253 SeriesStatus.FUTURE,
254 )]
255 else:
256 # Other archives may have reasons to continue building at least
257 # for OBSOLETE series. For example, a PPA may be continuing to
258 # provide custom builds for users who haven't upgraded yet.
259 consider_series = self.distro.series
260
261 for distroseries in consider_series:
240 for pocket in self.archive.getPockets():262 for pocket in self.archive.getPockets():
241 allowed = (263 allowed = (
242 not self.allowed_suites or264 not self.allowed_suites or
243265
=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
--- lib/lp/archivepublisher/tests/test_publisher.py 2011-12-30 06:14:56 +0000
+++ lib/lp/archivepublisher/tests/test_publisher.py 2012-01-03 01:07:25 +0000
@@ -56,6 +56,7 @@
56from lp.soyuz.interfaces.archive import IArchiveSet56from lp.soyuz.interfaces.archive import IArchiveSet
57from lp.soyuz.tests.test_publishing import TestNativePublishingBase57from lp.soyuz.tests.test_publishing import TestNativePublishingBase
58from lp.testing import TestCaseWithFactory58from lp.testing import TestCaseWithFactory
59from lp.testing.fakemethod import FakeMethod
59from lp.testing.gpgkeys import gpgkeysdir60from lp.testing.gpgkeys import gpgkeysdir
60from lp.testing.keyserver import KeyServerTac61from lp.testing.keyserver import KeyServerTac
61from lp.testing.layers import ZopelessDatabaseLayer62from lp.testing.layers import ZopelessDatabaseLayer
@@ -431,6 +432,45 @@
431 # remove locally created dir432 # remove locally created dir
432 shutil.rmtree(test_pool_dir)433 shutil.rmtree(test_pool_dir)
433434
435 def testPublishingSkipsObsoleteFuturePrimarySeries(self):
436 """Publisher skips OBSOLETE/FUTURE series in PRIMARY archives."""
437 publisher = Publisher(
438 self.logger, self.config, self.disk_pool,
439 self.ubuntutest.main_archive)
440 # Remove security proxy so that the publisher can call our fake
441 # method.
442 publisher.distro = removeSecurityProxy(publisher.distro)
443
444 for status in (SeriesStatus.OBSOLETE, SeriesStatus.FUTURE):
445 naked_breezy_autotest = publisher.distro['breezy-autotest']
446 naked_breezy_autotest.status = status
447 naked_breezy_autotest.publish = FakeMethod(result=set())
448
449 publisher.A_publish(False)
450
451 self.assertEqual(0, naked_breezy_autotest.publish.call_count)
452
453 def testPublishingConsidersObsoleteFuturePPASeries(self):
454 """Publisher does not skip OBSOLETE/FUTURE series in PPA archives."""
455 ubuntu_team = getUtility(IPersonSet).getByName('ubuntu-team')
456 test_archive = getUtility(IArchiveSet).new(
457 distribution=self.ubuntutest, owner=ubuntu_team,
458 purpose=ArchivePurpose.PPA)
459 publisher = Publisher(
460 self.logger, self.config, self.disk_pool, test_archive)
461 # Remove security proxy so that the publisher can call our fake
462 # method.
463 publisher.distro = removeSecurityProxy(publisher.distro)
464
465 for status in (SeriesStatus.OBSOLETE, SeriesStatus.FUTURE):
466 naked_breezy_autotest = publisher.distro['breezy-autotest']
467 naked_breezy_autotest.status = status
468 naked_breezy_autotest.publish = FakeMethod(result=set())
469
470 publisher.A_publish(False)
471
472 self.assertEqual(1, naked_breezy_autotest.publish.call_count)
473
434 def testPublisherBuilderFunctions(self):474 def testPublisherBuilderFunctions(self):
435 """Publisher can be initialized via provided helper function.475 """Publisher can be initialized via provided helper function.
436476