Merge lp:~cjwatson/launchpad/remove-query-distro-pending-suites into lp:launchpad
| Status: | Merged |
|---|---|
| Approved by: | Jeroen T. Vermeulen on 2012-04-10 |
| Approved revision: | no longer in the source branch. |
| Merged at revision: | 15073 |
| Proposed branch: | lp:~cjwatson/launchpad/remove-query-distro-pending-suites |
| Merge into: | lp:launchpad |
| Diff against target: |
372 lines (+36/-141) 6 files modified
lib/lp/archivepublisher/scripts/publish_ftpmaster.py (+17/-16) lib/lp/archivepublisher/tests/test_publish_ftpmaster.py (+3/-3) lib/lp/soyuz/scripts/querydistro.py (+1/-76) lib/lp/soyuz/scripts/tests/germinate-test-data/mock-lp-root/scripts/ftpmaster-tools/lp-query-distro.py (+4/-8) lib/lp/soyuz/scripts/tests/test_lpquerydistro.py (+11/-33) scripts/ftpmaster-tools/lp-query-distro.py (+0/-5) |
| To merge this branch: | bzr merge lp:~cjwatson/launchpad/remove-query-distro-pending-suites |
| Related bugs: |
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Jeroen T. Vermeulen (community) | 2012-04-07 | Approve on 2012-04-09 | |
|
Review via email:
|
|||
Commit Message
Remove now-pointless indirection through LpQueryDistro pending_suites, and remove several other obsolete actions.
Description of the Change
== Summary ==
The "pending_suites" action in the lp-query-distro.py script (and the LpQueryDistro script class) made sense when the ftpmaster publisher script was a shell script; pending_suites is used in exactly one place, to discover whether any security suites are pending publication (see r6303.1.2). However, since it was rewritten in Python, it's just pointless indirection, not to mention inefficient because it means setting up and tearing down a LaunchpadScript instance. PublishFTPMaster can just talk to the database directly. We can refactor this.
I also noticed that several other LpQueryDistro actions are no longer used, and removed them; and likewise from a mock version of lp-query-distro.py in use in the cron.germinate tests. (It probably wouldn't be desperately hard to get rid of the entire script at this point, but that's a matter for another day and another branch.)
I think it's extremely unlikely that we'll need this code in future and regret removing it. lp-query-distro.py was always mainly for shell scripts that nobody had got round to rewriting in Python yet, and anything new that needs to know about this stuff is very likely to be in Python. There was a secondary goal at one point of helping out local archive administration scripts on ftpmaster, but we have nothing left that uses lp-query-distro.py and anything new we write will be based on the API.
== Tests ==
bin/test -vvct test_lpquerydistro -t test_publish_
== lint ==
Just one false positive:
./scripts/
23: '_pythonpath' imported but unused
| Jeroen T. Vermeulen (jtv) wrote : | # |
Wow. It's a good thing I was substantially done with that review, because it submitted by accident as I was trying to turn off a caps lock that had gotten accidentally enabled. I have no idea what made Chromium submit the form. You can still tell where I was typing at “BI'll.”
| Colin Watson (cjwatson) wrote : | # |
On Mon, Apr 09, 2012 at 05:38:18AM -0000, Jeroen T. Vermeulen wrote:
> Just a small note, partly because it bothered me to see one piece of code growing a bit instead of shrinking:
I should point out for the record that I just moved this code around; I
didn't actually write it originally. (That said, obviously I don't
object to improving it.)
> As far as I can make out, the return value will duplicate a suite name between architectures (where "source" is effectively also an architecture). BI'll assume that's not what you want.
I can't see how that's the case. pending_suites is a set, so that deals
with deduplication.
Thanks for the suggestions about rewriting this section of code, though.
I hadn't previously known anything about the bulk loading interfaces
inside Launchpad, so that was a good thing to learn about. I can't
imagine that it loads a particularly large number of distroarchseries -
this script only touches Ubuntu, and there are only 32 active
distroarchseries in Ubuntu right now - but it doesn't hurt to load them
in one go anyway. I've pushed a modified version for your delectation
and delight.
| Jeroen T. Vermeulen (jtv) wrote : | # |
Thanks. I was mistaken about the duplications.

This makes me very happy. It's one thing to say “we should look into cleaning this up some day,” but actually doing it is another. It's also a very well-written merge proposal and it very much looks like a good branch.
Just a small note, partly because it bothered me to see one piece of code growing a bit instead of shrinking:
=== modified file 'lib/lp/ archivepublishe r/scripts/ publish_ ftpmaster. py' archivepublishe r/scripts/ publish_ ftpmaster. py 2012-02-28 04:24:19 +0000 archivepublishe r/scripts/ publish_ ftpmaster. py 2012-04-07 14:59:21 +0000
--- lib/lp/
+++ lib/lp/
@@ -329,12 +324,20 @@ self, distribution):
self. logger. debug(" Querying which suites are pending publication...") runAction( presenter= receiver) argument. split() main_archive. getPublishedSou rces( PackagePublishi ngStatus. PENDING) suites. add((pub. distroseries, pub.pocket)) main_archive. getAllPublished Binaries( PackagePublishi ngStatus. PENDING) suites. add((pub. distroarchserie s.distroseries, pub.pocket)) pocket]
def getDirtySuites(
"""Return list of suites that have packages pending publication."""
- query_distro = LpQueryDistro(
- test_args=['-d', distribution.name, "pending_suites"],
- logger=self.logger)
- receiver = StoreArgument()
- query_distro.
- return receiver.
+
+ pending_suites = set()
+ pending_sources = distribution.
+ status=
+ for pub in pending_sources:
+ pending_
*
+ pending_binaries = distribution.
+ status=
+ for pub in pending_binaries:
+ pending_
+
+ return [distroseries.name + pocketsuffix[
+ for distroseries, pocket in pending_suites]
As far as I can make out, the return value will duplicate a suite name between architectures (where "source" is effectively also an architecture). BI'll assume that's not what you want.
If it weren't for performance, the code could have been written more simply as:
archive = distribution. main_archive ngStatus. PENDING
pending_ sources = list(archive. getPublishedSou rces(pending) )
pending_ binaries = list(archive. getAllPublished Binaries( pending) )
pub. distroseries. name + pocketsuffix[ pub.pocket]
pending = PackagePublishi
return set(
for pub in pending_sources + pending_binaries)
If the pending_binaries bit could fetch a large number of distroarchseries from the database — I'm assuming the number of distroseries will be small and probably already in memory — you can bulk-load those using load_related using a single query:
archive = distribution. main_archive ngStatus. PENDING
pending_ sources = list(archive. getPublishedSou rces(pending) )
pending_ binaries = list(archive. getAllPublished Binaries( pending) )
load_related( DistroArchSerie s, pending_binaries, 'distroarchseri es_id')
pub. distroseries. name + pocketsuffix[ pub.pocket]
pending = PackagePublishi
return set(
for pub in pending_sources + pending_binaries)
This does return a set instead of a list. But I can't think of any problems that might cause.