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
=== modified file 'src/maasserver/rpc/boot.py'
--- src/maasserver/rpc/boot.py 2017-04-26 13:44:20 +0000
+++ src/maasserver/rpc/boot.py 2017-06-01 06:16:36 +0000
@@ -1,4 +1,4 @@
1# Copyright 2016 Canonical Ltd. This software is licensed under the1# Copyright 2016-2017 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""RPC helpers for getting the configuration for a booting machine."""4"""RPC helpers for getting the configuration for a booting machine."""
@@ -269,11 +269,22 @@
269 arch = DEFAULT_ARCH269 arch = DEFAULT_ARCH
270 else:270 else:
271 arch, _ = resource.split_arch()271 arch, _ = resource.split_arch()
272 # The subarch defines what kernel is booted. With MAAS 2.1 this changed
273 # from hwe-<letter> to hwe-<version> or ga-<version>. Validation
274 # converts between the two formats to make sure a bootable subarch is
275 # selected.
272 if subarch is None:276 if subarch is None:
273 if min_hwe_kernel:277 min_hwe_kernel = validate_hwe_kernel(
274 subarch = min_hwe_kernel278 None, min_hwe_kernel, '%s/generic' % arch, osystem, series)
275 else:279 else:
276 subarch = 'generic'280 min_hwe_kernel = validate_hwe_kernel(
281 None, min_hwe_kernel, '%s/%s' % (arch, subarch), osystem,
282 series)
283 # If no hwe_kernel was found set the subarch to the default, 'generic.'
284 if min_hwe_kernel is None:
285 subarch = 'generic'
286 else:
287 subarch = min_hwe_kernel
277288
278 # Global kernel options for enlistment.289 # Global kernel options for enlistment.
279 extra_kernel_opts = Config.objects.get_config("kernel_opts")290 extra_kernel_opts = Config.objects.get_config("kernel_opts")
280291
=== modified file 'src/maasserver/rpc/tests/test_boot.py'
--- src/maasserver/rpc/tests/test_boot.py 2017-04-26 13:44:20 +0000
+++ src/maasserver/rpc/tests/test_boot.py 2017-06-01 06:16:36 +0000
@@ -1,4 +1,4 @@
1# Copyright 2016 Canonical Ltd. This software is licensed under the1# Copyright 2016-2017 Canonical Ltd. This software is licensed under the
2# GNU Affero General Public License version 3 (see the file LICENSE).2# GNU Affero General Public License version 3 (see the file LICENSE).
33
4"""Tests for boot configuration retrieval from RPC."""4"""Tests for boot configuration retrieval from RPC."""
@@ -149,7 +149,7 @@
149 remote_ip = factory.make_ip_address()149 remote_ip = factory.make_ip_address()
150 expected_arch = tuple(150 expected_arch = tuple(
151 make_usable_architecture(151 make_usable_architecture(
152 self, arch_name="i386", subarch_name="generic").split("/"))152 self, arch_name="i386", subarch_name="hwe-16.04").split("/"))
153 observed_config = get_config(153 observed_config = get_config(
154 rack_controller.system_id, local_ip, remote_ip)154 rack_controller.system_id, local_ip, remote_ip)
155 observed_arch = observed_config["arch"], observed_config["subarch"]155 observed_arch = observed_config["arch"], observed_config["subarch"]
@@ -209,14 +209,26 @@
209 local_ip = factory.make_ip_address()209 local_ip = factory.make_ip_address()
210 remote_ip = factory.make_ip_address()210 remote_ip = factory.make_ip_address()
211 arch = 'armhf'211 arch = 'armhf'
212 Config.objects.set_config('default_min_hwe_kernel', 'hwe-v')212 Config.objects.set_config('default_min_hwe_kernel', 'hwe-x')
213 self.patch(boot_module, 'get_boot_filenames').return_value = (213 self.patch(boot_module, 'get_boot_filenames').return_value = (
214 None, None, None)214 None, None, None)
215 observed_config = get_config(215 factory.make_default_ubuntu_release_bootable(arch)
216 rack_controller.system_id, local_ip, remote_ip, arch=arch)216 observed_config = get_config(
217 self.assertEqual(217 rack_controller.system_id, local_ip, remote_ip, arch=arch)
218 "hwe-v",218 self.assertEqual('hwe-16.04', observed_config['subarch'])
219 observed_config["subarch"])219
220 def test__enlistment_return_generic_when_none(self):
221 rack_controller = factory.make_RackController()
222 local_ip = factory.make_ip_address()
223 remote_ip = factory.make_ip_address()
224 arch = 'armhf'
225 self.patch(boot_module, 'get_boot_filenames').return_value = (
226 None, None, None)
227 self.patch(boot_module, 'validate_hwe_kernel').return_value = None
228 factory.make_default_ubuntu_release_bootable(arch)
229 observed_config = get_config(
230 rack_controller.system_id, local_ip, remote_ip, arch=arch)
231 self.assertEqual('generic', observed_config['subarch'])
220232
221 def test__has_preseed_url_for_known_node(self):233 def test__has_preseed_url_for_known_node(self):
222 rack_controller = factory.make_RackController()234 rack_controller = factory.make_RackController()