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
1=== modified file 'lib/lp/archivepublisher/domination.py'
2--- lib/lp/archivepublisher/domination.py 2012-08-17 11:15:35 +0000
3+++ lib/lp/archivepublisher/domination.py 2013-02-25 05:33:23 +0000
4@@ -517,6 +517,7 @@
5 binarypackagepublishinghistory.distroarchseries =
6 distroarchseries.id AND
7 binarypackagepublishinghistory.scheduleddeletiondate IS NULL AND
8+ binarypackagepublishinghistory.dateremoved IS NULL AND
9 binarypackagepublishinghistory.archive = %s AND
10 binarypackagebuild.source_package_release = %s AND
11 distroarchseries.distroseries = %s AND
12@@ -786,7 +787,8 @@
13 sourcepackagepublishinghistory.archive = %s AND
14 sourcepackagepublishinghistory.pocket = %s AND
15 sourcepackagepublishinghistory.status IN %s AND
16- sourcepackagepublishinghistory.scheduleddeletiondate is NULL
17+ sourcepackagepublishinghistory.scheduleddeletiondate is NULL AND
18+ sourcepackagepublishinghistory.dateremoved is NULL
19 """ % sqlvalues(
20 distroseries, self.archive, pocket,
21 inactive_publishing_status))
22@@ -798,7 +800,8 @@
23 binarypackagepublishinghistory.archive = %s AND
24 binarypackagepublishinghistory.pocket = %s AND
25 binarypackagepublishinghistory.status IN %s AND
26- binarypackagepublishinghistory.scheduleddeletiondate is NULL
27+ binarypackagepublishinghistory.scheduleddeletiondate is NULL AND
28+ binarypackagepublishinghistory.dateremoved is NULL
29 """ % sqlvalues(
30 distroseries, self.archive, pocket,
31 inactive_publishing_status),
32
33=== modified file 'lib/lp/archivepublisher/publishing.py'
34--- lib/lp/archivepublisher/publishing.py 2013-02-20 04:02:11 +0000
35+++ lib/lp/archivepublisher/publishing.py 2013-02-25 05:33:23 +0000
36@@ -96,9 +96,6 @@
37 It ensures the given archive location matches the minimal structure
38 required.
39 """
40- log.debug("Making directories as needed.")
41- pubconf.setupArchiveDirs()
42-
43 log.debug("Preparing on-disk pool representation.")
44 dp = DiskPool(pubconf.poolroot, pubconf.temproot,
45 logging.getLogger("DiskPool"))
46@@ -145,8 +142,6 @@
47
48 disk_pool = _getDiskPool(pubconf, log)
49
50- _setupHtaccess(archive, pubconf, log)
51-
52 if distsroot is not None:
53 log.debug("Overriding dists root with %s." % distsroot)
54 pubconf.distsroot = distsroot
55@@ -197,9 +192,6 @@
56 self.archive = archive
57 self.allowed_suites = allowed_suites
58
59- if not os.path.isdir(config.poolroot):
60- raise ValueError("Root %s is not a directory or does "
61- "not exist" % config.poolroot)
62 self._diskpool = diskpool
63
64 if library is None:
65@@ -217,6 +209,11 @@
66 # This is a set of tuples in the form (distroseries.name, pocket)
67 self.release_files_needed = set()
68
69+ def setupArchiveDirs(self):
70+ self.log.debug("Setting up archive directories.")
71+ self._config.setupArchiveDirs()
72+ _setupHtaccess(self.archive, self._config, self.log)
73+
74 def isDirty(self, distroseries, pocket):
75 """True if a publication has happened in this release and pocket."""
76 return (distroseries.name, pocket) in self.dirty_pockets
77
78=== modified file 'lib/lp/archivepublisher/tests/test_publisher.py'
79--- lib/lp/archivepublisher/tests/test_publisher.py 2013-02-20 04:02:11 +0000
80+++ lib/lp/archivepublisher/tests/test_publisher.py 2013-02-25 05:33:23 +0000
81@@ -167,6 +167,7 @@
82 dead_bpph.supersede()
83
84 publisher = getPublisher(test_archive, None, self.logger)
85+ publisher.setupArchiveDirs()
86
87 self.assertTrue(os.path.exists(publisher._config.archiveroot))
88
89@@ -212,6 +213,7 @@
90 purpose=ArchivePurpose.PPA)
91 logger = BufferLogger()
92 publisher = getPublisher(test_archive, None, logger)
93+ publisher.setupArchiveDirs()
94
95 self.assertTrue(os.path.exists(publisher._config.archiveroot))
96
97@@ -1133,8 +1135,8 @@
98 ppa.buildd_secret = "geheim"
99
100 # Set up the publisher for it and publish its repository.
101- # 'getPublisher' is what actually configures the htaccess file.
102- getPublisher(ppa, [], self.logger)
103+ # setupArchiveDirs is what actually configures the htaccess file.
104+ getPublisher(ppa, [], self.logger).setupArchiveDirs()
105 pubconf = getPubConfig(ppa)
106 htaccess_path = os.path.join(pubconf.htaccessroot, ".htaccess")
107 self.assertTrue(os.path.exists(htaccess_path))
108
109=== modified file 'lib/lp/registry/model/distribution.py'
110--- lib/lp/registry/model/distribution.py 2013-02-06 09:15:36 +0000
111+++ lib/lp/registry/model/distribution.py 2013-02-25 05:33:23 +0000
112@@ -1275,7 +1275,8 @@
113 Archive.purpose = %s AND
114 Archive.distribution = %s AND
115 SourcePackagePublishingHistory.archive = archive.id AND
116- SourcePackagePublishingHistory.scheduleddeletiondate is null AND
117+ SourcePackagePublishingHistory.scheduleddeletiondate IS NULL AND
118+ SourcePackagePublishingHistory.dateremoved IS NULL AND
119 SourcePackagePublishingHistory.status IN (%s, %s)
120 """ % sqlvalues(ArchivePurpose.PPA, self,
121 PackagePublishingStatus.PENDING,
122@@ -1289,7 +1290,8 @@
123 Archive.purpose = %s AND
124 Archive.distribution = %s AND
125 BinaryPackagePublishingHistory.archive = archive.id AND
126- BinaryPackagePublishingHistory.scheduleddeletiondate is null AND
127+ BinaryPackagePublishingHistory.scheduleddeletiondate IS NULL AND
128+ BinaryPackagePublishingHistory.dateremoved IS NULL AND
129 BinaryPackagePublishingHistory.status IN (%s, %s)
130 """ % sqlvalues(ArchivePurpose.PPA, self,
131 PackagePublishingStatus.PENDING,
132
133=== modified file 'lib/lp/soyuz/doc/distribution.txt'
134--- lib/lp/soyuz/doc/distribution.txt 2012-12-05 16:16:20 +0000
135+++ lib/lp/soyuz/doc/distribution.txt 2013-02-25 05:33:23 +0000
136@@ -236,11 +236,20 @@
137 >>> pending_ppa.id == cprov.archive.id
138 True
139
140+If scheduleddeletiondate or dateremoved are set then the PPA is no
141+longer pending. process-death-row will do the rest.
142+
143 >>> login('mark@example.com')
144 >>> from lp.services.database.constants import UTC_NOW
145 >>> src_pub.scheduleddeletiondate = UTC_NOW
146 >>> ubuntu.getPendingPublicationPPAs().count()
147 0
148+ >>> src_pub.scheduleddeletiondate = None
149+ >>> ubuntu.getPendingPublicationPPAs().count()
150+ 1
151+ >>> src_pub.dateremoved = UTC_NOW
152+ >>> ubuntu.getPendingPublicationPPAs().count()
153+ 0
154
155 A binary pending publication also moves a PPA to the pending-publication
156 state. In order to test this behaviour we will copy some binaries within
157@@ -285,6 +294,12 @@
158 >>> bin_pub.scheduleddeletiondate = UTC_NOW
159 >>> ubuntu.getPendingPublicationPPAs().count()
160 0
161+ >>> bin_pub.scheduleddeletiondate = None
162+ >>> ubuntu.getPendingPublicationPPAs().count()
163+ 1
164+ >>> bin_pub.dateremoved = UTC_NOW
165+ >>> ubuntu.getPendingPublicationPPAs().count()
166+ 0
167
168
169 Distribution Archives
170
171=== modified file 'lib/lp/soyuz/scripts/publishdistro.py'
172--- lib/lp/soyuz/scripts/publishdistro.py 2012-06-29 08:40:05 +0000
173+++ lib/lp/soyuz/scripts/publishdistro.py 2013-02-25 05:33:23 +0000
174@@ -300,6 +300,7 @@
175
176 Commits transactions along the way.
177 """
178+ publisher.setupArchiveDirs()
179 publisher.A_publish(self.isCareful(self.options.careful_publishing))
180 self.txn.commit()
181