Merge lp:~wgrant/launchpad/export-das-chroot into lp:launchpad

Proposed by William Grant
Status: Merged
Approved by: Julian Edwards
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~wgrant/launchpad/export-das-chroot
Merge into: lp:launchpad
Diff against target: 92 lines (+42/-0)
4 files modified
lib/lp/soyuz/doc/distroarchseries.txt (+14/-0)
lib/lp/soyuz/interfaces/distroarchseries.py (+7/-0)
lib/lp/soyuz/model/distroarchseries.py (+8/-0)
lib/lp/soyuz/stories/webservice/xx-distroarchseries.txt (+13/-0)
To merge this branch: bzr merge lp:~wgrant/launchpad/export-das-chroot
Reviewer Review Type Date Requested Status
Julian Edwards (community) Approve
Björn Tillenius (community) Approve
Leonard Richardson Pending
Review via email: mp+19759@code.launchpad.net

Commit message

Export DistroArchSeries chroot URLs on the webservice.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

This trivial branch adds and exports IDistroArchSeries.chroot_url. I think that just about says it all.

Revision history for this message
Björn Tillenius (bjornt) wrote :

Why not export getChroot() instead? It seems more useful to get the actual librarian file, rather than just a URL.

review: Needs Information
Revision history for this message
William Grant (wgrant) wrote :

On Sat, 2010-02-20 at 08:11 +0000, Björn Tillenius wrote:
> Review: Needs Information
> Why not export getChroot() instead? It seems more useful to get the actual librarian file, rather than just a URL.

ILFA isn't exported at the moment. All other places I can find seem to
just export a URL, and Julian suggested doing that on the bug. It would
be really nice to have attributes like hashes visible, though.

Revision history for this message
Björn Tillenius (bjornt) wrote :

On Sat, Feb 20, 2010 at 12:50:33AM -0000, William Grant wrote:
> === modified file 'lib/lp/soyuz/doc/distroarchseries.txt'
> --- lib/lp/soyuz/doc/distroarchseries.txt 2009-10-26 18:40:04 +0000
> +++ lib/lp/soyuz/doc/distroarchseries.txt 2010-02-20 00:50:31 +0000
> @@ -344,6 +344,14 @@
> >>> print_architectures(hoary.enabled_architectures)
> The Hoary Hedgehog Release for hppa (hppa) (ppa)
>
> +The architecture also has a 'chroot_url' attribute directly referencing
> +the file.
> +
> + >>> print hoary.getDistroArchSeries('hppa').chroot_url
> + http://localhost:58000/.../filename...
> + >>> print hoary.getDistroArchSeries('i386').chroot_url
> + None

When is chroot_url None? It'd be good to document this. Also, for test
correctness, I'd also (in addition to the current test) compare
chroot_url to getChroot().http_url, so that you know that you're not
returning just any URL.

> === modified file 'lib/lp/soyuz/interfaces/distroarchseries.py'
> --- lib/lp/soyuz/interfaces/distroarchseries.py 2009-07-17 00:26:05 +0000
> +++ lib/lp/soyuz/interfaces/distroarchseries.py 2010-02-20 00:50:31 +0000
> @@ -108,6 +108,12 @@
> Interface, # Really IArchive, circular import fixed below.
> title=_('Main Archive'),
> description=_("The main archive of the distroarchseries.")))
> + chroot_url = exported(
> + TextLine(
> + title=_("Build chroot URL"),
> + description=_(
> + "The URL to the current build chroot for this "
> + "distroarchseries.")))
>
> def updatePackageCount():
> """Update the cached binary package count for this distro arch
>
> === modified file 'lib/lp/soyuz/model/distroarchseries.py'
> --- lib/lp/soyuz/model/distroarchseries.py 2009-12-24 06:57:25 +0000
> +++ lib/lp/soyuz/model/distroarchseries.py 2010-02-20 00:50:31 +0000
> @@ -136,6 +136,13 @@
>
> return pocket_chroot.chroot
>
> + @property
> + def chroot_url(self):
> + chroot = self.getChroot()

This should have a """See `IDistroArchSeries`.""" docstring.

I'm approving this branch with these small comments resolved.

    vote approve

--
Björn Tillenius | https://launchpad.net/~bjornt

review: Approve
Revision history for this message
Julian Edwards (julian-edwards) wrote :

> Why not export getChroot() instead? It seems more useful to get the actual
> librarian file, rather than just a URL.

chroots are several hundred meg big - way too much to proxy through the webapp.

We return URLs as a matter of course for most objects now, Launchpad needs to be quicker, not slower when we tie up an app sever.

Revision history for this message
Julian Edwards (julian-edwards) wrote :

This bit should have some explanation text to say why this set up is needed. Otherwise, looks great, thanks for the fix William.

63 + >>> from zope.component import getUtility
64 + >>> from lp.registry.interfaces.distribution import IDistributionSet
65 +
66 + >>> login('<email address hidden>')
67 + >>> hoary = getUtility(IDistributionSet)['ubuntu'].getSeries('hoary')
68 + >>> chroot = factory.makeLibraryFileAlias()
69 + >>> unused = hoary.getDistroArchSeries('i386').addOrUpdateChroot(chroot)
70 + >>> logout()
71 +

review: Approve
Revision history for this message
Björn Tillenius (bjornt) wrote :

On Mon, Feb 22, 2010 at 10:27:17AM -0000, Julian Edwards wrote:
> > Why not export getChroot() instead? It seems more useful to get the actual
> > librarian file, rather than just a URL.
>
> chroots are several hundred meg big - way too much to proxy through the webapp.

Why does this matter if ILibraryFileAlias is exported, exposing meta
data, including http_url?

--
Björn Tillenius | https://launchpad.net/~bjornt

Revision history for this message
Julian Edwards (julian-edwards) wrote :

> On Mon, Feb 22, 2010 at 10:27:17AM -0000, Julian Edwards wrote:
> > > Why not export getChroot() instead? It seems more useful to get the actual
> > > librarian file, rather than just a URL.
> >
> > chroots are several hundred meg big - way too much to proxy through the
> webapp.
>
> Why does this matter if ILibraryFileAlias is exported, exposing meta
> data, including http_url?

Oh I see, expose the LFA. Yeah that would be ok, but I'd do it in addition to the other URL so that it's not yet another traversal to get the data you need. And LFA is not currently exported of course :)

Revision history for this message
Francis J. Lacoste (flacoste) wrote :

On February 22, 2010, Julian Edwards wrote:
> > On Mon, Feb 22, 2010 at 10:27:17AM -0000, Julian Edwards wrote:
> > > > Why not export getChroot() instead? It seems more useful to get the
> > > > actual librarian file, rather than just a URL.
> > >
> > > chroots are several hundred meg big - way too much to proxy through the
> >
> > webapp.
> >
> > Why does this matter if ILibraryFileAlias is exported, exposing meta
> > data, including http_url?
>
> Oh I see, expose the LFA. Yeah that would be ok, but I'd do it in addition
> to the other URL so that it's not yet another traversal to get the data
> you need. And LFA is not currently exported of course :)

We don't want to export LibraryFileAlias directly. These are mapped to
HostedFile in the web service implementation.

  reviewer leonardr

Leonard, could you give us some pointers on how this should be mapped to a
HostedFile.

Thanks

--
Francis J. Lacoste
<email address hidden>

Revision history for this message
William Grant (wgrant) wrote :

So, this was discussed a bit on IRC, but no real consensus was reached. Should I change it to export an IBytes, or should I be consistent with most of the rest of the application and export a librarian URL until we can export LFA more sanely?

Revision history for this message
Julian Edwards (julian-edwards) wrote :

> So, this was discussed a bit on IRC, but no real consensus was reached. Should
> I change it to export an IBytes, or should I be consistent with most of the
> rest of the application and export a librarian URL until we can export LFA
> more sanely?

I would be consistent and land the change that exports the URL. I'll land it for you today.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/soyuz/doc/distroarchseries.txt'
2--- lib/lp/soyuz/doc/distroarchseries.txt 2009-10-26 18:40:04 +0000
3+++ lib/lp/soyuz/doc/distroarchseries.txt 2010-02-22 10:48:27 +0000
4@@ -344,6 +344,20 @@
5 >>> print_architectures(hoary.enabled_architectures)
6 The Hoary Hedgehog Release for hppa (hppa) (ppa)
7
8+The architecture also has a 'chroot_url' attribute directly referencing
9+the file.
10+
11+ >>> print hoary.getDistroArchSeries('hppa').chroot_url
12+ http://localhost:58000/.../filename...
13+ >>> hoary.getDistroArchSeries('hppa').chroot_url == \
14+ ... chroot.http_url
15+ True
16+
17+If there is no chroot, chroot_url will be None.
18+
19+ >>> print hoary.getDistroArchSeries('i386').chroot_url
20+ None
21+
22 `DistroSeries.enabled_architectures` results are ordered
23 alphabetically by 'architecturetag'.
24
25
26=== modified file 'lib/lp/soyuz/interfaces/distroarchseries.py'
27--- lib/lp/soyuz/interfaces/distroarchseries.py 2009-07-17 00:26:05 +0000
28+++ lib/lp/soyuz/interfaces/distroarchseries.py 2010-02-22 10:48:27 +0000
29@@ -108,6 +108,13 @@
30 Interface, # Really IArchive, circular import fixed below.
31 title=_('Main Archive'),
32 description=_("The main archive of the distroarchseries.")))
33+ chroot_url = exported(
34+ TextLine(
35+ title=_("Build chroot URL"),
36+ description=_(
37+ "The URL to the current build chroot for this "
38+ "distroarchseries."),
39+ readonly=True))
40
41 def updatePackageCount():
42 """Update the cached binary package count for this distro arch
43
44=== modified file 'lib/lp/soyuz/model/distroarchseries.py'
45--- lib/lp/soyuz/model/distroarchseries.py 2009-12-24 06:57:25 +0000
46+++ lib/lp/soyuz/model/distroarchseries.py 2010-02-22 10:48:27 +0000
47@@ -136,6 +136,14 @@
48
49 return pocket_chroot.chroot
50
51+ @property
52+ def chroot_url(self):
53+ """See `IDistroArchSeries`."""
54+ chroot = self.getChroot()
55+ if chroot is None:
56+ return None
57+ return chroot.http_url
58+
59 def addOrUpdateChroot(self, chroot):
60 """See `IDistroArchSeries`."""
61 pocket_chroot = self.getPocketChroot()
62
63=== renamed file 'lib/canonical/launchpad/pagetests/webservice/xx-distroarchseries.txt' => 'lib/lp/soyuz/stories/webservice/xx-distroarchseries.txt'
64--- lib/canonical/launchpad/pagetests/webservice/xx-distroarchseries.txt 2009-08-13 15:12:16 +0000
65+++ lib/lp/soyuz/stories/webservice/xx-distroarchseries.txt 2010-02-22 10:48:27 +0000
66@@ -13,6 +13,18 @@
67 >>> print current_series['self_link']
68 http://.../ubuntu/hoary
69
70+We'll first set up a buildd chroot, so we can check that its URL is
71+exposed.
72+
73+ >>> from zope.component import getUtility
74+ >>> from lp.registry.interfaces.distribution import IDistributionSet
75+
76+ >>> login('foo.bar@canonical.com')
77+ >>> hoary = getUtility(IDistributionSet)['ubuntu'].getSeries('hoary')
78+ >>> chroot = factory.makeLibraryFileAlias()
79+ >>> unused = hoary.getDistroArchSeries('i386').addOrUpdateChroot(chroot)
80+ >>> logout()
81+
82 >>> distroarchseries = webservice.named_get(
83 ... current_series['self_link'], 'getDistroArchSeries',
84 ... archtag='i386').jsonBody()
85@@ -22,6 +34,7 @@
86 >>> from lazr.restful.testing.webservice import pprint_entry
87 >>> pprint_entry(distroarchseries)
88 architecture_tag: u'i386'
89+ chroot_url: u'http://localhost:58000/.../filename...'
90 display_name: u'Ubuntu Hoary i386'
91 distroseries_link: u'http://.../ubuntu/hoary'
92 is_nominated_arch_indep: True