← Back to team overview

launchpad-reviewers team mailing list archive

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

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/snap-build-channels-remove-proxy into lp:launchpad.

Commit message:
Remove security proxy from snap channels dict sent to builders.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/snap-build-channels-remove-proxy/+merge/341965

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
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/snap-build-channels-remove-proxy into lp:launchpad.
=== modified file 'lib/lp/snappy/model/snapbuildbehaviour.py'
--- lib/lp/snappy/model/snapbuildbehaviour.py	2018-03-22 16:48:16 +0000
+++ lib/lp/snappy/model/snapbuildbehaviour.py	2018-03-23 13:31:23 +0000
@@ -19,6 +19,7 @@
 from twisted.web.client import getPage
 from zope.component import adapter
 from zope.interface import implementer
+from zope.security.proxy import removeSecurityProxy
 
 from lp.buildmaster.interfaces.builder import CannotBuild
 from lp.buildmaster.interfaces.buildfarmjobbehaviour import (
@@ -110,7 +111,10 @@
         args["archive_private"] = build.archive.private
         args["build_url"] = canonical_url(build)
         if build.channels is not None:
-            args["channels"] = build.channels
+            # We have to remove the security proxy that Zope applies to this
+            # dict, since otherwise we'll be unable to serialise it to
+            # XML-RPC.
+            args["channels"] = removeSecurityProxy(build.channels)
         if build.snap.branch is not None:
             args["branch"] = build.snap.branch.bzr_identity
         elif build.snap.git_ref is not None:

=== modified file 'lib/lp/snappy/tests/test_snapbuildbehaviour.py'
--- lib/lp/snappy/tests/test_snapbuildbehaviour.py	2018-03-22 16:48:16 +0000
+++ lib/lp/snappy/tests/test_snapbuildbehaviour.py	2018-03-23 13:31:23 +0000
@@ -31,6 +31,7 @@
 from twisted.internet import defer
 from twisted.trial.unittest import TestCase as TrialTestCase
 from zope.component import getUtility
+from zope.proxy import isProxy
 from zope.security.proxy import removeSecurityProxy
 
 from lp.archivepublisher.interfaces.archivesigningkey import (
@@ -410,6 +411,7 @@
             yield get_sources_list_for_building(
                 job.build, job.build.distro_arch_series, None))
         args = yield job._extraBuildArgs()
+        self.assertFalse(isProxy(args["channels"]))
         self.assertEqual({"snapcraft": "edge"}, args["channels"])
 
     @defer.inlineCallbacks


Follow ups