Merge lp:~cjwatson/launchpad-buildd/lxd-powerpc into lp:launchpad-buildd

Proposed by Colin Watson
Status: Merged
Merged at revision: 277
Proposed branch: lp:~cjwatson/launchpad-buildd/lxd-powerpc
Merge into: lp:launchpad-buildd
Diff against target: 175 lines (+73/-41)
3 files modified
debian/changelog (+7/-0)
lpbuildd/target/lxd.py (+22/-15)
lpbuildd/target/tests/test_lxd.py (+44/-26)
To merge this branch: bzr merge lp:~cjwatson/launchpad-buildd/lxd-powerpc
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+330208@code.launchpad.net

Commit message

Tell LXD to disable seccomp on powerpc, since it doesn't work there on Linux 4.4.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) :
review: Approve (code)
280. By Colin Watson

Add comment for powerpc seccomp issues.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'debian/changelog'
--- debian/changelog 2017-09-01 12:52:20 +0000
+++ debian/changelog 2017-09-06 09:37:21 +0000
@@ -1,3 +1,10 @@
1launchpad-buildd (150) UNRELEASED; urgency=medium
2
3 * Tell LXD to disable seccomp on powerpc, since it doesn't work there on
4 Linux 4.4.
5
6 -- Colin Watson <cjwatson@ubuntu.com> Tue, 05 Sep 2017 10:41:55 +0100
7
1launchpad-buildd (149) xenial; urgency=medium8launchpad-buildd (149) xenial; urgency=medium
29
3 * Clamp the TCP MSS on the LXD bridge interface to the path MTU, to avoid10 * Clamp the TCP MSS on the LXD bridge interface to the path MTU, to avoid
411
=== modified file 'lpbuildd/target/lxd.py'
--- lpbuildd/target/lxd.py 2017-09-01 12:47:09 +0000
+++ lpbuildd/target/lxd.py 2017-09-06 09:37:21 +0000
@@ -245,10 +245,7 @@
245 os.unlink(self.dnsmasq_pid_file)245 os.unlink(self.dnsmasq_pid_file)
246 subprocess.call(["sudo", "ip", "link", "delete", self.bridge_name])246 subprocess.call(["sudo", "ip", "link", "delete", self.bridge_name])
247247
248 def start(self):248 def create_profile(self):
249 """See `Backend`."""
250 self.stop()
251
252 for addr in self.ipv4_network:249 for addr in self.ipv4_network:
253 if addr not in (250 if addr not in (
254 self.ipv4_network.network, self.ipv4_network.ip,251 self.ipv4_network.network, self.ipv4_network.ip,
@@ -267,20 +264,25 @@
267 else:264 else:
268 old_profile.delete()265 old_profile.delete()
269266
267 raw_lxc_config = [
268 ("lxc.aa_profile", "unconfined"),
269 ("lxc.cgroup.devices.deny", ""),
270 ("lxc.cgroup.devices.allow", ""),
271 ("lxc.mount.auto", ""),
272 ("lxc.mount.auto", "proc:rw sys:rw"),
273 ("lxc.network.0.ipv4", ipv4_address),
274 ("lxc.network.0.ipv4.gateway", self.ipv4_network.ip),
275 ]
276 # Linux 4.4 on powerpc doesn't support all the seccomp bits that LXD
277 # needs.
278 if self.arch == "powerpc":
279 raw_lxc_config.append(("lxc.seccomp", ""))
270 config = {280 config = {
271 "security.privileged": "true",281 "security.privileged": "true",
272 "security.nesting": "true",282 "security.nesting": "true",
273 "raw.lxc": dedent("""\283 "raw.lxc": "".join(
274 lxc.aa_profile=unconfined284 "{key}={value}\n".format(key=key, value=value)
275 lxc.cgroup.devices.deny=285 for key, value in raw_lxc_config),
276 lxc.cgroup.devices.allow=
277 lxc.mount.auto=
278 lxc.mount.auto=proc:rw sys:rw
279 lxc.network.0.ipv4={ipv4_address}
280 lxc.network.0.ipv4.gateway={ipv4_gateway}
281 """.format(
282 ipv4_address=ipv4_address,
283 ipv4_gateway=self.ipv4_network.ip)),
284 }286 }
285 devices = {287 devices = {
286 "eth0": {288 "eth0": {
@@ -292,6 +294,11 @@
292 }294 }
293 self.client.profiles.create(self.profile_name, config, devices)295 self.client.profiles.create(self.profile_name, config, devices)
294296
297 def start(self):
298 """See `Backend`."""
299 self.stop()
300
301 self.create_profile()
295 self.start_bridge()302 self.start_bridge()
296303
297 container = self.client.containers.create({304 container = self.client.containers.create({
298305
=== modified file 'lpbuildd/target/tests/test_lxd.py'
--- lpbuildd/target/tests/test_lxd.py 2017-09-01 12:47:09 +0000
+++ lpbuildd/target/tests/test_lxd.py 2017-09-06 09:37:21 +0000
@@ -122,32 +122,8 @@
122 image.add_alias.assert_called_once_with(122 image.add_alias.assert_called_once_with(
123 "lp-xenial-amd64", "lp-xenial-amd64")123 "lp-xenial-amd64", "lp-xenial-amd64")
124124
125 def test_start(self):125 def assert_correct_profile(self, extra_raw_lxc_config=""):
126 fs_fixture = self.useFixture(FakeFilesystem())
127 fs_fixture.add("/sys")
128 fs_fixture.add("/run")
129 os.makedirs("/run/launchpad-buildd")
130 fs_fixture.add("/etc")
131 os.mkdir("/etc")
132 with open("/etc/resolv.conf", "w") as f:
133 print("host resolv.conf", file=f)
134 os.chmod("/etc/resolv.conf", 0o644)
135 self.useFixture(MockPatch("pylxd.Client"))
136 client = pylxd.Client()126 client = pylxd.Client()
137 client.profiles.get.side_effect = FakeLXDAPIException
138 container = client.containers.create.return_value
139 client.containers.get.return_value = container
140 container.start.side_effect = (
141 lambda wait=False: setattr(container, "status_code", LXD_RUNNING))
142 files_api = container.api.files
143 files_api._api_endpoint = "/1.0/containers/lp-xenial-amd64/files"
144 files_api.session.get.return_value.status_code = 200
145 files_api.session.get.return_value.iter_content.return_value = (
146 iter([b"127.0.0.1\tlocalhost\n"]))
147 processes_fixture = self.useFixture(FakeProcesses())
148 processes_fixture.add(lambda _: {}, name="sudo")
149 LXD("1", "xenial", "amd64").start()
150
151 client.profiles.get.assert_called_once_with("lpbuildd")127 client.profiles.get.assert_called_once_with("lpbuildd")
152 expected_config = {128 expected_config = {
153 "security.privileged": "true",129 "security.privileged": "true",
@@ -160,7 +136,7 @@
160 lxc.mount.auto=proc:rw sys:rw136 lxc.mount.auto=proc:rw sys:rw
161 lxc.network.0.ipv4=10.10.10.2/24137 lxc.network.0.ipv4=10.10.10.2/24
162 lxc.network.0.ipv4.gateway=10.10.10.1138 lxc.network.0.ipv4.gateway=10.10.10.1
163 """),139 """) + extra_raw_lxc_config,
164 }140 }
165 expected_devices = {141 expected_devices = {
166 "eth0": {142 "eth0": {
@@ -173,6 +149,48 @@
173 client.profiles.create.assert_called_once_with(149 client.profiles.create.assert_called_once_with(
174 "lpbuildd", expected_config, expected_devices)150 "lpbuildd", expected_config, expected_devices)
175151
152 def test_create_profile_amd64(self):
153 self.useFixture(MockPatch("pylxd.Client"))
154 client = pylxd.Client()
155 client.profiles.get.side_effect = FakeLXDAPIException
156 LXD("1", "xenial", "amd64").create_profile()
157 self.assert_correct_profile()
158
159 def test_create_profile_powerpc(self):
160 self.useFixture(MockPatch("pylxd.Client"))
161 client = pylxd.Client()
162 client.profiles.get.side_effect = FakeLXDAPIException
163 LXD("1", "xenial", "powerpc").create_profile()
164 self.assert_correct_profile("lxc.seccomp=\n")
165
166 def test_start(self):
167 fs_fixture = self.useFixture(FakeFilesystem())
168 fs_fixture.add("/sys")
169 fs_fixture.add("/run")
170 os.makedirs("/run/launchpad-buildd")
171 fs_fixture.add("/etc")
172 os.mkdir("/etc")
173 with open("/etc/resolv.conf", "w") as f:
174 print("host resolv.conf", file=f)
175 os.chmod("/etc/resolv.conf", 0o644)
176 self.useFixture(MockPatch("pylxd.Client"))
177 client = pylxd.Client()
178 client.profiles.get.side_effect = FakeLXDAPIException
179 container = client.containers.create.return_value
180 client.containers.get.return_value = container
181 container.start.side_effect = (
182 lambda wait=False: setattr(container, "status_code", LXD_RUNNING))
183 files_api = container.api.files
184 files_api._api_endpoint = "/1.0/containers/lp-xenial-amd64/files"
185 files_api.session.get.return_value.status_code = 200
186 files_api.session.get.return_value.iter_content.return_value = (
187 iter([b"127.0.0.1\tlocalhost\n"]))
188 processes_fixture = self.useFixture(FakeProcesses())
189 processes_fixture.add(lambda _: {}, name="sudo")
190 LXD("1", "xenial", "amd64").start()
191
192 self.assert_correct_profile()
193
176 ip = ["sudo", "ip"]194 ip = ["sudo", "ip"]
177 iptables = ["sudo", "iptables", "-w"]195 iptables = ["sudo", "iptables", "-w"]
178 iptables_comment = [196 iptables_comment = [

Subscribers

People subscribed via source and target branches

to all changes: