Merge lp:~rvb/maas/comm-templ-bug-1410367 into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 3477
Proposed branch: lp:~rvb/maas/comm-templ-bug-1410367
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 257 lines (+119/-34)
8 files modified
etc/maas/templates/pxe/config.commissioning.template (+5/-16)
etc/maas/templates/pxe/config.enlist.template (+19/-0)
etc/maas/templates/pxe/config.xinstall.template (+5/-16)
etc/maas/templates/uefi/config.enlist.template (+8/-0)
src/maasserver/api/pxeconfig.py (+10/-1)
src/maasserver/api/tests/test_pxeconfig.py (+6/-0)
src/provisioningserver/boot/tests/test_pxe.py (+29/-1)
src/provisioningserver/boot/tests/test_uefi.py (+37/-0)
To merge this branch: bzr merge lp:~rvb/maas/comm-templ-bug-1410367
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+246569@code.launchpad.net

Commit message

In the commissioning and the xinstall templates, ditch the architecture auto-detection and use what's provided in the boot parameters.

Description of the change

It's not entirely clear to me why we were using ifcpu64.c32 in the first place (it's been like that since inception) so I'm putting this up for review to get feedback.
I've tested this on my NUCs but I'm planning to do some additional testing once the CI is green again.

To post a comment you must log in.
Revision history for this message
Blake Rouse (blake-rouse) wrote :

Looks good.

The ifcpu64 should only exists in the enlist template so the correct architecture is loaded for the kernel and initramfs. I guess it just happened to get copied into the commissioning script, its amazing it has been like this for this long.

review: Approve
Revision history for this message
Raphaël Badin (rvb) wrote :

> The ifcpu64 should only exists in the enlist template so the correct architecture is loaded for
> the kernel and initramfs. I guess it just happened to get copied into the commissioning
> script, its amazing it has been like this for this long.

Turns out the commissioning and the enlistment templates were the same… hence the bug. I've added an enlistment template for the case where arch-detection needs to happen.

Revision history for this message
Blake Rouse (blake-rouse) wrote :

You need you to add a uefi/config.enlist.template as well. The UEFIBootMethod will expect having that template as well since the pxeconfig call was changed to return enlist.

review: Needs Fixing
Revision history for this message
Raphaël Badin (rvb) wrote :

> You need you to add a uefi/config.enlist.template as well. The UEFIBootMethod
> will expect having that template as well since the pxeconfig call was changed
> to return enlist.

Well spotted! I added the template along with a couple of missing tests.

Revision history for this message
Blake Rouse (blake-rouse) wrote :

Awesome! Thanks for fixing it up.

A CI run would be good to make sure this is correct, but I don't know if that is fully working yet with the transaction issues.

review: Approve
Revision history for this message
Raphaël Badin (rvb) wrote :

> Awesome! Thanks for fixing it up.
>
> A CI run would be good to make sure this is correct, but I don't know if that
> is fully working yet with the transaction issues.

Already done, and it's working fine (http://162.213.35.104:8080/job/maas-utopic-trunk-manual/25/). And I also tested on my NUCs.

Don't forget you're talking to the CI police here :).

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'etc/maas/templates/pxe/config.commissioning.template'
--- etc/maas/templates/pxe/config.commissioning.template 2013-06-05 06:19:05 +0000
+++ etc/maas/templates/pxe/config.commissioning.template 2015-01-19 13:41:25 +0000
@@ -1,20 +1,9 @@
1DEFAULT execute1DEFAULT execute
22
3SAY Booting under MAAS direction...
4SAY {{kernel_params() | kernel_command}}
5
6LABEL execute3LABEL execute
7 KERNEL ifcpu64.c324 SAY Booting under MAAS direction...
8 APPEND amd64 -- i3865 SAY {{kernel_params() | kernel_command}}
96 KERNEL {{kernel_params | kernel_path }}
10LABEL amd647 INITRD {{kernel_params | initrd_path }}
11 KERNEL {{kernel_params(arch="amd64") | kernel_path }}8 APPEND {{kernel_params | kernel_command}}
12 INITRD {{kernel_params(arch="amd64") | initrd_path }}
13 APPEND {{kernel_params(arch="amd64") | kernel_command}}
14 IPAPPEND 2
15
16LABEL i386
17 KERNEL {{kernel_params(arch="i386") | kernel_path }}
18 INITRD {{kernel_params(arch="i386") | initrd_path }}
19 APPEND {{kernel_params(arch="i386") | kernel_command}}
20 IPAPPEND 29 IPAPPEND 2
2110
=== added file 'etc/maas/templates/pxe/config.enlist.template'
--- etc/maas/templates/pxe/config.enlist.template 1970-01-01 00:00:00 +0000
+++ etc/maas/templates/pxe/config.enlist.template 2015-01-19 13:41:25 +0000
@@ -0,0 +1,19 @@
1DEFAULT execute
2
3SAY Booting under MAAS direction...
4SAY {{kernel_params() | kernel_command}}
5
6LABEL execute
7 KERNEL ifcpu64.c32
8 APPEND amd64 -- i386
9
10LABEL amd64
11 KERNEL {{kernel_params(arch="amd64") | kernel_path }}
12 INITRD {{kernel_params(arch="amd64") | initrd_path }}
13 APPEND {{kernel_params(arch="amd64") | kernel_command}}
14 IPAPPEND 2
15
16LABEL i386
17 KERNEL {{kernel_params(arch="i386") | kernel_path }}
18 INITRD {{kernel_params(arch="i386") | initrd_path }}
19 APPEND {{kernel_params(arch="i386") | kernel_command}}
020
=== modified file 'etc/maas/templates/pxe/config.xinstall.template'
--- etc/maas/templates/pxe/config.xinstall.template 2013-06-03 11:32:28 +0000
+++ etc/maas/templates/pxe/config.xinstall.template 2015-01-19 13:41:25 +0000
@@ -1,20 +1,9 @@
1DEFAULT execute1DEFAULT execute
22
3SAY Booting under MAAS direction...
4SAY {{kernel_params() | kernel_command}}
5
6LABEL execute3LABEL execute
7 KERNEL ifcpu64.c324 SAY Booting under MAAS direction...
8 APPEND amd64 -- i3865 SAY {{kernel_params() | kernel_command}}
96 KERNEL {{kernel_params | kernel_path }}
10LABEL amd647 INITRD {{kernel_params | initrd_path }}
11 KERNEL {{kernel_params(arch="amd64") | kernel_path }}8 APPEND {{kernel_params | kernel_command}}
12 INITRD {{kernel_params(arch="amd64") | initrd_path }}
13 APPEND {{kernel_params(arch="amd64") | kernel_command}}
14 IPAPPEND 2
15
16LABEL i386
17 KERNEL {{kernel_params(arch="i386") | kernel_path }}
18 INITRD {{kernel_params(arch="i386") | initrd_path }}
19 APPEND {{kernel_params(arch="i386") | kernel_command}}
20 IPAPPEND 29 IPAPPEND 2
2110
=== added file 'etc/maas/templates/uefi/config.enlist.template'
--- etc/maas/templates/uefi/config.enlist.template 1970-01-01 00:00:00 +0000
+++ etc/maas/templates/uefi/config.enlist.template 2015-01-19 13:41:25 +0000
@@ -0,0 +1,8 @@
1set default="0"
2set timeout=0
3
4menuentry 'Enlist' {
5 echo 'Booting under MAAS direction...'
6 linux {{kernel_params | kernel_path }} {{kernel_params | kernel_command}} BOOTIF=01-${net_default_mac}
7 initrd {{kernel_params | initrd_path }}
8}
09
=== modified file 'src/maasserver/api/pxeconfig.py'
--- src/maasserver/api/pxeconfig.py 2014-12-12 19:21:25 +0000
+++ src/maasserver/api/pxeconfig.py 2015-01-19 13:41:25 +0000
@@ -135,6 +135,9 @@
135 event_description=options[purpose])135 event_description=options[purpose])
136136
137137
138DEFAULT_ARCH = 'i386'
139
140
138def pxeconfig(request):141def pxeconfig(request):
139 """Get the PXE configuration given a node's details.142 """Get the PXE configuration given a node's details.
140143
@@ -214,7 +217,7 @@
214 BootResource.objects.get_default_commissioning_resource(217 BootResource.objects.get_default_commissioning_resource(
215 osystem, series))218 osystem, series))
216 if resource is None:219 if resource is None:
217 arch = 'i386'220 arch = DEFAULT_ARCH
218 else:221 else:
219 arch, _ = resource.split_arch()222 arch, _ = resource.split_arch()
220223
@@ -293,6 +296,12 @@
293 server_address = get_maas_facing_server_address(nodegroup=nodegroup)296 server_address = get_maas_facing_server_address(nodegroup=nodegroup)
294 cluster_address = get_mandatory_param(request.GET, "local")297 cluster_address = get_mandatory_param(request.GET, "local")
295298
299 # If the node is enlisting and the arch is the default arch (i386),
300 # use the dedicated enlistment template which performs architecture
301 # detection.
302 if node is None and arch == DEFAULT_ARCH:
303 boot_purpose = "enlist"
304
296 params = KernelParameters(305 params = KernelParameters(
297 osystem=osystem, arch=arch, subarch=subarch, release=series,306 osystem=osystem, arch=arch, subarch=subarch, release=series,
298 label=label, purpose=boot_purpose, hostname=hostname, domain=domain,307 label=label, purpose=boot_purpose, hostname=hostname, domain=domain,
299308
=== modified file 'src/maasserver/api/tests/test_pxeconfig.py'
--- src/maasserver/api/tests/test_pxeconfig.py 2014-12-12 19:21:25 +0000
+++ src/maasserver/api/tests/test_pxeconfig.py 2015-01-19 13:41:25 +0000
@@ -396,11 +396,17 @@
396 # test that purpose is set to "commissioning" for396 # test that purpose is set to "commissioning" for
397 # enlistment (when node is None).397 # enlistment (when node is None).
398 params = self.get_default_params()398 params = self.get_default_params()
399 params['arch'] = 'armhf'
399 response = self.client.get(reverse('pxeconfig'), params)400 response = self.client.get(reverse('pxeconfig'), params)
400 self.assertEqual(401 self.assertEqual(
401 "commissioning",402 "commissioning",
402 json.loads(response.content)["purpose"])403 json.loads(response.content)["purpose"])
403404
405 def test_pxeconfig_returns_enlist_config_if_no_architecture_provided(self):
406 params = self.get_default_params()
407 pxe_config = self.get_pxeconfig(params)
408 self.assertEqual('enlist', pxe_config['purpose'])
409
404 def test_pxeconfig_returns_fs_host_as_cluster_controller(self):410 def test_pxeconfig_returns_fs_host_as_cluster_controller(self):
405 # The kernel parameter `fs_host` points to the cluster controller411 # The kernel parameter `fs_host` points to the cluster controller
406 # address, which is passed over within the `local` parameter.412 # address, which is passed over within the `local` parameter.
407413
=== modified file 'src/provisioningserver/boot/tests/test_pxe.py'
--- src/provisioningserver/boot/tests/test_pxe.py 2014-09-18 12:44:38 +0000
+++ src/provisioningserver/boot/tests/test_pxe.py 2015-01-19 13:41:25 +0000
@@ -324,6 +324,34 @@
324 ]324 ]
325325
326 def test_get_reader_scenarios(self):326 def test_get_reader_scenarios(self):
327 method = PXEBootMethod()
328 get_ephemeral_name = self.patch(kernel_opts, "get_ephemeral_name")
329 get_ephemeral_name.return_value = factory.make_name("ephemeral")
330 osystem = factory.make_name('osystem')
331 arch = factory.make_name('arch')
332 subarch = factory.make_name('subarch')
333 options = {
334 "backend": None,
335 "kernel_params": make_kernel_parameters(
336 testcase=self, osystem=osystem, subarch=subarch,
337 arch=arch, purpose=self.purpose),
338 }
339 output = method.get_reader(**options).read(10000)
340 config = parse_pxe_config(output)
341 # The default section is defined.
342 default_section_label = config.header["DEFAULT"]
343 self.assertThat(config, Contains(default_section_label))
344 default_section = dict(config[default_section_label])
345
346 contains_arch_path = StartsWith("%s/%s/%s" % (osystem, arch, subarch))
347 self.assertThat(default_section["KERNEL"], contains_arch_path)
348 self.assertThat(default_section["INITRD"], contains_arch_path)
349 self.assertEquals("2", default_section["IPAPPEND"])
350
351
352class TestPXEBootMethodRenderConfigScenariosEnlist(MAASTestCase):
353
354 def test_get_reader_scenarios(self):
327 # The commissioning config uses an extra PXELINUX module to auto355 # The commissioning config uses an extra PXELINUX module to auto
328 # select between i386 and amd64.356 # select between i386 and amd64.
329 method = PXEBootMethod()357 method = PXEBootMethod()
@@ -334,7 +362,7 @@
334 "backend": None,362 "backend": None,
335 "kernel_params": make_kernel_parameters(363 "kernel_params": make_kernel_parameters(
336 testcase=self, osystem=osystem, subarch="generic",364 testcase=self, osystem=osystem, subarch="generic",
337 purpose=self.purpose),365 purpose='enlist'),
338 }366 }
339 output = method.get_reader(**options).read(10000)367 output = method.get_reader(**options).read(10000)
340 config = parse_pxe_config(output)368 config = parse_pxe_config(output)
341369
=== modified file 'src/provisioningserver/boot/tests/test_uefi.py'
--- src/provisioningserver/boot/tests/test_uefi.py 2014-09-18 12:44:38 +0000
+++ src/provisioningserver/boot/tests/test_uefi.py 2015-01-19 13:41:25 +0000
@@ -33,6 +33,7 @@
33from provisioningserver.rpc.testing import MockLiveClusterToRegionRPCFixture33from provisioningserver.rpc.testing import MockLiveClusterToRegionRPCFixture
34from provisioningserver.tests.test_kernel_opts import make_kernel_parameters34from provisioningserver.tests.test_kernel_opts import make_kernel_parameters
35from testtools.matchers import (35from testtools.matchers import (
36 ContainsAll,
36 IsInstance,37 IsInstance,
37 MatchesAll,38 MatchesAll,
38 MatchesRegex,39 MatchesRegex,
@@ -152,6 +153,42 @@
152 output = method.get_reader(**options).read(10000)153 output = method.get_reader(**options).read(10000)
153 self.assertIn("configfile /efi/ubuntu/grub.cfg", output)154 self.assertIn("configfile /efi/ubuntu/grub.cfg", output)
154155
156 def test_get_reader_with_enlist_purpose(self):
157 # If purpose is "enlist", the config.enlist.template should be
158 # used.
159 method = UEFIBootMethod()
160 params = make_kernel_parameters(
161 purpose="enlist", arch="amd64")
162 options = {
163 "backend": None,
164 "kernel_params": params,
165 }
166 output = method.get_reader(**options).read(10000)
167 self.assertThat(output, ContainsAll(
168 [
169 "menuentry 'Enlist'",
170 "%s/%s/%s" % (params.osystem, params.arch, params.subarch),
171 "boot-kernel",
172 ]))
173
174 def test_get_reader_with_commissioning_purpose(self):
175 # If purpose is "commissioning", the config.commissioning.template
176 # should be used.
177 method = UEFIBootMethod()
178 params = make_kernel_parameters(
179 purpose="commissioning", arch="amd64")
180 options = {
181 "backend": None,
182 "kernel_params": params,
183 }
184 output = method.get_reader(**options).read(10000)
185 self.assertThat(output, ContainsAll(
186 [
187 "menuentry 'Commission'",
188 "%s/%s/%s" % (params.osystem, params.arch, params.subarch),
189 "boot-kernel",
190 ]))
191
155192
156class TestUEFIBootMethodRegex(MAASTestCase):193class TestUEFIBootMethodRegex(MAASTestCase):
157 """Tests `provisioningserver.boot.uefi.UEFIBootMethod.re_config_file`."""194 """Tests `provisioningserver.boot.uefi.UEFIBootMethod.re_config_file`."""