← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad-buildd/snapd-no-cdn into lp:launchpad-buildd

 

Colin Watson has proposed merging lp:~cjwatson/launchpad-buildd/snapd-no-cdn into lp:launchpad-buildd.

Commit message:
Run snapd with SNAPPY_STORE_NO_CDN=1, since the buildd network isn't
allowed to talk to the CDN.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad-buildd/snapd-no-cdn/+merge/330366
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad-buildd/snapd-no-cdn into lp:launchpad-buildd.
=== modified file 'debian/changelog'
--- debian/changelog	2017-09-06 11:30:39 +0000
+++ debian/changelog	2017-09-07 14:56:03 +0000
@@ -1,3 +1,10 @@
+launchpad-buildd (151) UNRELEASED; urgency=medium
+
+  * Run snapd with SNAPPY_STORE_NO_CDN=1, since the buildd network isn't
+    allowed to talk to the CDN.
+
+ -- Colin Watson <cjwatson@xxxxxxxxxx>  Thu, 07 Sep 2017 15:52:10 +0100
+
 launchpad-buildd (150) xenial; urgency=medium
 
   * Tell LXD to disable seccomp on powerpc, since it doesn't work there on

=== modified file 'lpbuildd/target/lxd.py'
--- lpbuildd/target/lxd.py	2017-09-06 09:39:12 +0000
+++ lpbuildd/target/lxd.py	2017-09-07 14:56:03 +0000
@@ -360,6 +360,21 @@
             raise BackendException(
                 "Container failed to start within %d seconds" % timeout)
 
+        # XXX cjwatson 2017-09-07: With LXD < 2.2 we can't create the
+        # directory until the container has started.  We can get away with
+        # this for the time being because snapd isn't in the buildd chroots.
+        self.run(["mkdir", "-p", "/etc/systemd/system/snapd.service.d"])
+        with tempfile.NamedTemporaryFile(mode="w+") as no_cdn_file:
+            print(dedent("""\
+                [Service]
+                Environment=SNAPPY_STORE_NO_CDN=1
+                """), file=no_cdn_file, end="")
+            no_cdn_file.flush()
+            os.fchmod(no_cdn_file.fileno(), 0o644)
+            self.copy_in(
+                no_cdn_file.name,
+                "/etc/systemd/system/snapd.service.d/no-cdn.conf")
+
     def run(self, args, env=None, input_text=None, get_output=False,
             echo=False, **kwargs):
         """See `Backend`."""

=== modified file 'lpbuildd/target/tests/test_lxd.py'
--- lpbuildd/target/tests/test_lxd.py	2017-09-06 09:31:04 +0000
+++ lpbuildd/target/tests/test_lxd.py	2017-09-07 14:56:03 +0000
@@ -200,6 +200,7 @@
             iter([b"127.0.0.1\tlocalhost\n"]))
         processes_fixture = self.useFixture(FakeProcesses())
         processes_fixture.add(lambda _: {}, name="sudo")
+        processes_fixture.add(lambda _: {}, name="lxc")
         LXD("1", "xenial", "amd64").start()
 
         self.assert_correct_profile()
@@ -237,6 +238,9 @@
                      "--pid-file=/run/launchpad-buildd/dnsmasq.pid",
                      "--except-interface=lo", "--interface=lpbuilddbr0",
                      "--listen-address=10.10.10.1"]),
+                Equals(
+                    ["lxc", "exec", "lp-xenial-amd64", "--", "linux64",
+                     "mkdir", "-p", "/etc/systemd/system/snapd.service.d"]),
                 ]))
 
         client.containers.create.assert_called_once_with({
@@ -263,6 +267,10 @@
             params={"path": "/usr/local/sbin/policy-rc.d"},
             data=policy_rc_d.encode("UTF-8"),
             headers={"X-LXD-uid": 0, "X-LXD-gid": 0, "X-LXD-mode": "0755"})
+        files_api.post.assert_any_call(
+            params={"path": "/etc/systemd/system/snapd.service.d/no-cdn.conf"},
+            data=b"[Service]\nEnvironment=SNAPPY_STORE_NO_CDN=1\n",
+            headers={"X-LXD-uid": 0, "X-LXD-gid": 0, "X-LXD-mode": "0644"})
         container.start.assert_called_once_with(wait=True)
         self.assertEqual(LXD_RUNNING, container.status_code)
 
@@ -291,6 +299,7 @@
             }
         processes_fixture = self.useFixture(FakeProcesses())
         processes_fixture.add(lambda _: {}, name="sudo")
+        processes_fixture.add(lambda _: {}, name="lxc")
         LXD("1", "xenial", "amd64").start()
 
         files_api.session.get.assert_called_once_with(