Merge lp:~ltrager/maas/lp1693644 into lp:~maas-committers/maas/trunk

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: no longer in the source branch.
Merged at revision: 6069
Proposed branch: lp:~ltrager/maas/lp1693644
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 90 lines (+38/-15)
2 files modified
src/maasserver/rpc/boot.py (+16/-5)
src/maasserver/rpc/tests/test_boot.py (+22/-10)
To merge this branch: bzr merge lp:~ltrager/maas/lp1693644
Reviewer Review Type Date Requested Status
Данило Шеган (community) Approve
Review via email: mp+324658@code.launchpad.net

Commit message

Validate the min_hwe_kernel on enlistment.

To post a comment you must log in.
Revision history for this message
Данило Шеган (danilo) wrote :

Thanks Lee for working on this: it generally looks good, but since I am not well versed in all the concepts, can you please respond to my question inline?

review: Needs Information
Revision history for this message
Lee Trager (ltrager) wrote :

Thanks for the review. I've updated the patch to clean up the code a little and add a comment to try and explain as well as responded inline.

Revision history for this message
Данило Шеган (danilo) wrote :

Looks good, thanks for the explanations!

(a few minor nits inline)

review: Approve
Revision history for this message
Lee Trager (ltrager) wrote :

Thanks for the suggestions, I've updated and added another test as suggested.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/rpc/boot.py'
2--- src/maasserver/rpc/boot.py 2017-04-26 13:44:20 +0000
3+++ src/maasserver/rpc/boot.py 2017-06-01 06:16:36 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2016 Canonical Ltd. This software is licensed under the
6+# Copyright 2016-2017 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 """RPC helpers for getting the configuration for a booting machine."""
10@@ -269,11 +269,22 @@
11 arch = DEFAULT_ARCH
12 else:
13 arch, _ = resource.split_arch()
14+ # The subarch defines what kernel is booted. With MAAS 2.1 this changed
15+ # from hwe-<letter> to hwe-<version> or ga-<version>. Validation
16+ # converts between the two formats to make sure a bootable subarch is
17+ # selected.
18 if subarch is None:
19- if min_hwe_kernel:
20- subarch = min_hwe_kernel
21- else:
22- subarch = 'generic'
23+ min_hwe_kernel = validate_hwe_kernel(
24+ None, min_hwe_kernel, '%s/generic' % arch, osystem, series)
25+ else:
26+ min_hwe_kernel = validate_hwe_kernel(
27+ None, min_hwe_kernel, '%s/%s' % (arch, subarch), osystem,
28+ series)
29+ # If no hwe_kernel was found set the subarch to the default, 'generic.'
30+ if min_hwe_kernel is None:
31+ subarch = 'generic'
32+ else:
33+ subarch = min_hwe_kernel
34
35 # Global kernel options for enlistment.
36 extra_kernel_opts = Config.objects.get_config("kernel_opts")
37
38=== modified file 'src/maasserver/rpc/tests/test_boot.py'
39--- src/maasserver/rpc/tests/test_boot.py 2017-04-26 13:44:20 +0000
40+++ src/maasserver/rpc/tests/test_boot.py 2017-06-01 06:16:36 +0000
41@@ -1,4 +1,4 @@
42-# Copyright 2016 Canonical Ltd. This software is licensed under the
43+# Copyright 2016-2017 Canonical Ltd. This software is licensed under the
44 # GNU Affero General Public License version 3 (see the file LICENSE).
45
46 """Tests for boot configuration retrieval from RPC."""
47@@ -149,7 +149,7 @@
48 remote_ip = factory.make_ip_address()
49 expected_arch = tuple(
50 make_usable_architecture(
51- self, arch_name="i386", subarch_name="generic").split("/"))
52+ self, arch_name="i386", subarch_name="hwe-16.04").split("/"))
53 observed_config = get_config(
54 rack_controller.system_id, local_ip, remote_ip)
55 observed_arch = observed_config["arch"], observed_config["subarch"]
56@@ -209,14 +209,26 @@
57 local_ip = factory.make_ip_address()
58 remote_ip = factory.make_ip_address()
59 arch = 'armhf'
60- Config.objects.set_config('default_min_hwe_kernel', 'hwe-v')
61- self.patch(boot_module, 'get_boot_filenames').return_value = (
62- None, None, None)
63- observed_config = get_config(
64- rack_controller.system_id, local_ip, remote_ip, arch=arch)
65- self.assertEqual(
66- "hwe-v",
67- observed_config["subarch"])
68+ Config.objects.set_config('default_min_hwe_kernel', 'hwe-x')
69+ self.patch(boot_module, 'get_boot_filenames').return_value = (
70+ None, None, None)
71+ factory.make_default_ubuntu_release_bootable(arch)
72+ observed_config = get_config(
73+ rack_controller.system_id, local_ip, remote_ip, arch=arch)
74+ self.assertEqual('hwe-16.04', observed_config['subarch'])
75+
76+ def test__enlistment_return_generic_when_none(self):
77+ rack_controller = factory.make_RackController()
78+ local_ip = factory.make_ip_address()
79+ remote_ip = factory.make_ip_address()
80+ arch = 'armhf'
81+ self.patch(boot_module, 'get_boot_filenames').return_value = (
82+ None, None, None)
83+ self.patch(boot_module, 'validate_hwe_kernel').return_value = None
84+ factory.make_default_ubuntu_release_bootable(arch)
85+ observed_config = get_config(
86+ rack_controller.system_id, local_ip, remote_ip, arch=arch)
87+ self.assertEqual('generic', observed_config['subarch'])
88
89 def test__has_preseed_url_for_known_node(self):
90 rack_controller = factory.make_RackController()