Merge lp:~cjwatson/launchpad/snap-build-channels-remove-proxy into lp:launchpad

Proposed by Colin Watson
Status: Merged
Merged at revision: 18581
Proposed branch: lp:~cjwatson/launchpad/snap-build-channels-remove-proxy
Merge into: lp:launchpad
Diff against target: 43 lines (+7/-1)
2 files modified
lib/lp/snappy/model/snapbuildbehaviour.py (+5/-1)
lib/lp/snappy/tests/test_snapbuildbehaviour.py (+2/-0)
To merge this branch: bzr merge lp:~cjwatson/launchpad/snap-build-channels-remove-proxy
Reviewer Review Type Date Requested Status
Adam Collard (community) Approve
Launchpad code reviewers Pending
Review via email: mp+341965@code.launchpad.net

Commit message

Remove security proxy from snap channels dict sent to builders.

Description of the change

Otherwise build dispatch crashes like this:

2018-03-23 12:49:05+0000 [QueryProtocol,client] Scanning dogfood-lgw01-amd64-001 failed with: cannot marshal <type 'zope.security._proxy._Proxy'> objects

To post a comment you must log in.
Revision history for this message
Adam Collard (adam-collard) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/snappy/model/snapbuildbehaviour.py'
2--- lib/lp/snappy/model/snapbuildbehaviour.py 2018-03-22 16:48:16 +0000
3+++ lib/lp/snappy/model/snapbuildbehaviour.py 2018-03-23 13:31:23 +0000
4@@ -19,6 +19,7 @@
5 from twisted.web.client import getPage
6 from zope.component import adapter
7 from zope.interface import implementer
8+from zope.security.proxy import removeSecurityProxy
9
10 from lp.buildmaster.interfaces.builder import CannotBuild
11 from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
12@@ -110,7 +111,10 @@
13 args["archive_private"] = build.archive.private
14 args["build_url"] = canonical_url(build)
15 if build.channels is not None:
16- args["channels"] = build.channels
17+ # We have to remove the security proxy that Zope applies to this
18+ # dict, since otherwise we'll be unable to serialise it to
19+ # XML-RPC.
20+ args["channels"] = removeSecurityProxy(build.channels)
21 if build.snap.branch is not None:
22 args["branch"] = build.snap.branch.bzr_identity
23 elif build.snap.git_ref is not None:
24
25=== modified file 'lib/lp/snappy/tests/test_snapbuildbehaviour.py'
26--- lib/lp/snappy/tests/test_snapbuildbehaviour.py 2018-03-22 16:48:16 +0000
27+++ lib/lp/snappy/tests/test_snapbuildbehaviour.py 2018-03-23 13:31:23 +0000
28@@ -31,6 +31,7 @@
29 from twisted.internet import defer
30 from twisted.trial.unittest import TestCase as TrialTestCase
31 from zope.component import getUtility
32+from zope.proxy import isProxy
33 from zope.security.proxy import removeSecurityProxy
34
35 from lp.archivepublisher.interfaces.archivesigningkey import (
36@@ -410,6 +411,7 @@
37 yield get_sources_list_for_building(
38 job.build, job.build.distro_arch_series, None))
39 args = yield job._extraBuildArgs()
40+ self.assertFalse(isProxy(args["channels"]))
41 self.assertEqual({"snapcraft": "edge"}, args["channels"])
42
43 @defer.inlineCallbacks