Merge lp:~ltrager/maas/lp1629491 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: 5429
Proposed branch: lp:~ltrager/maas/lp1629491
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 133 lines (+52/-13)
5 files modified
src/maasserver/models/tests/test_bootresource.py (+3/-3)
src/maasserver/rpc/boot.py (+8/-1)
src/maasserver/rpc/tests/test_boot.py (+36/-7)
src/maasserver/utils/osystems.py (+4/-1)
src/maasserver/utils/tests/test_osystems.py (+1/-1)
To merge this branch: bzr merge lp:~ltrager/maas/lp1629491
Reviewer Review Type Date Requested Status
Blake Rouse (community) Approve
Review via email: mp+307458@code.launchpad.net

Commit message

Use validate_hwe_kernel when setting the commissiong kernel.

The kernel format changed from hwe-<letter> to hwe-<version> in 2.1. Users who upgraded from a previous version may still be using the old format in the min_hwe_kernel field. validate_hwe_kernel converts from the old format to the new transparently so commissioning continues to work.

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

Code looks good. As long as it works, ;-)

review: Approve
Revision history for this message
MAAS Lander (maas-lander) wrote :
Download full text (1.5 MiB)

The attempt to merge lp:~ltrager/maas/lp1629491 into lp:maas failed. Below is the output from the failed tests.

Hit:1 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Hit:2 http://security.ubuntu.com/ubuntu xenial-security InRelease
Get:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [95.7 kB]
Hit:4 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease
Fetched 95.7 kB in 0s (216 kB/s)
Reading package lists...
sudo DEBIAN_FRONTEND=noninteractive apt-get -y \
    --no-install-recommends install apache2 archdetect-deb authbind avahi-utils bash bind9 bind9utils build-essential bzr bzr-builddeb chromium-browser chromium-chromedriver curl daemontools debhelper dh-apport dh-systemd distro-info dnsutils firefox freeipmi-tools git gjs ipython isc-dhcp-common isc-dhcp-server libjs-angularjs libjs-jquery libjs-jquery-hotkeys libjs-yui3-full libjs-yui3-min libpq-dev make nodejs-legacy npm postgresql pxelinux python3-all python3-apt python3-attr python3-bson python3-convoy python3-crochet python3-cssselect python3-curtin python3-dev python3-distro-info python3-django python3-django-nose python3-django-piston3 python3-dnspython python3-docutils python3-formencode python3-hivex python3-httplib2 python3-jinja2 python3-jsonschema python3-lxml python3-netaddr python3-netifaces python3-novaclient python3-oauth python3-oauthlib python3-openssl python3-paramiko python3-petname python3-pexpect python3-psycopg2 python3-pyinotify python3-pyparsing python3-pyvmomi python3-requests python3-seamicroclient python3-setuptools python3-simplestreams python3-sphinx python3-tempita python3-twisted python3-txtftp python3-tz python3-yaml python3-zope.interface python-bson python-crochet python-django python-django-piston python-djorm-ext-pgarray python-formencode python-lxml python-netaddr python-netifaces python-pocket-lint python-psycopg2 python-simplejson python-tempita python-twisted python-yaml socat syslinux-common tgt ubuntu-cloudimage-keyring wget xvfb
Reading package lists...
Building dependency tree...
Reading state information...
archdetect-deb is already the newest version (1.117ubuntu2).
authbind is already the newest version (2.1.1+nmu1).
avahi-utils is already the newest version (0.6.32~rc+dfsg-1ubuntu2).
build-essential is already the newest version (12.1ubuntu2).
debhelper is already the newest version (9.20160115ubuntu3).
distro-info is already the newest version (0.14build1).
freeipmi-tools is already the newest version (1.4.11-1ubuntu1).
git is already the newest version (1:2.7.4-0ubuntu1).
libjs-angularjs is already the newest version (1.2.28-1ubuntu2).
libjs-jquery is already the newest version (1.11.3+dfsg-4).
libjs-yui3-full is already the newest version (3.5.1-1ubuntu3).
libjs-yui3-min is already the newest version (3.5.1-1ubuntu3).
make is already the newest version (4.1-6).
postgresql is already the newest version (9.5+173).
pxelinux is already the newest version (3:6.03+dfsg-11ubuntu1).
python-formencode is already the newest version (1.3.0-0ubuntu5).
python-lxml is already the newest version (3.5.0-1build1).
python-netaddr is already the newest version (0.7....

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/models/tests/test_bootresource.py'
2--- src/maasserver/models/tests/test_bootresource.py 2016-09-12 21:33:05 +0000
3+++ src/maasserver/models/tests/test_bootresource.py 2016-10-03 17:54:21 +0000
4@@ -649,9 +649,9 @@
5 name=self.name, rtype=BOOT_RESOURCE_TYPE.SYNCED,
6 architecture="%s/%s" % (self.arch, self.subarch))
7 self.assertEqual(
8- self.kernels,
9- BootResource.objects.get_usable_hwe_kernels(
10- self.name, self.arch),
11+ sorted(self.kernels),
12+ sorted(BootResource.objects.get_usable_hwe_kernels(
13+ self.name, self.arch)),
14 "%s should return %s as its usable kernel" % (
15 self.name, self.kernels))
16 self.assertEqual(
17
18=== modified file 'src/maasserver/rpc/boot.py'
19--- src/maasserver/rpc/boot.py 2016-09-30 22:08:43 +0000
20+++ src/maasserver/rpc/boot.py 2016-10-03 17:54:21 +0000
21@@ -7,6 +7,7 @@
22 "get_config",
23 ]
24
25+from django.core.exceptions import ValidationError
26 from maasserver.enum import INTERFACE_TYPE
27 from maasserver.models import (
28 BootResource,
29@@ -29,6 +30,7 @@
30 get_one,
31 transactional,
32 )
33+from maasserver.utils.osystems import validate_hwe_kernel
34 from provisioningserver.events import EVENT_TYPES
35 from provisioningserver.rpc.exceptions import BootConfigNoResponse
36 from provisioningserver.utils.twisted import synchronous
37@@ -157,7 +159,12 @@
38 elif(subarch == "generic" and
39 purpose == "commissioning" and
40 machine.min_hwe_kernel):
41- subarch = machine.min_hwe_kernel
42+ try:
43+ subarch = validate_hwe_kernel(
44+ None, machine.min_hwe_kernel, machine.architecture,
45+ osystem, series)
46+ except ValidationError:
47+ subarch = "no-such-kernel"
48
49 # We don't care if the kernel opts is from the global setting or a tag,
50 # just get the options
51
52=== modified file 'src/maasserver/rpc/tests/test_boot.py'
53--- src/maasserver/rpc/tests/test_boot.py 2016-08-18 17:31:05 +0000
54+++ src/maasserver/rpc/tests/test_boot.py 2016-10-03 17:54:21 +0000
55@@ -500,13 +500,42 @@
56 remote_ip = factory.make_ip_address()
57 node = factory.make_Node_with_Interface_on_Subnet(
58 status=NODE_STATUS.COMMISSIONING,
59- min_hwe_kernel="hwe-v")
60- mac = node.get_boot_interface().mac_address
61- observed_config = get_config(
62- rack_controller.system_id, local_ip, remote_ip, mac=mac)
63- self.assertEqual(
64- "hwe-v",
65- observed_config["subarch"])
66+ min_hwe_kernel="hwe-16.10")
67+ arch = node.split_arch()[0]
68+ ubuntu = factory.make_default_ubuntu_release_bootable(arch)
69+ factory.make_usable_boot_resource(
70+ name=ubuntu.name, architecture="%s/hwe-16.10" % arch,
71+ kflavor='generic', rtype=BOOT_RESOURCE_TYPE.SYNCED)
72+ mac = node.get_boot_interface().mac_address
73+ observed_config = get_config(
74+ rack_controller.system_id, local_ip, remote_ip, mac=mac)
75+ self.assertEqual("hwe-16.10", observed_config["subarch"])
76+
77+ def test__commissioning_node_uses_min_hwe_kernel_converted(self):
78+ rack_controller = factory.make_RackController()
79+ local_ip = factory.make_ip_address()
80+ remote_ip = factory.make_ip_address()
81+ node = factory.make_Node_with_Interface_on_Subnet(
82+ status=NODE_STATUS.COMMISSIONING,
83+ min_hwe_kernel="hwe-x")
84+ arch = node.split_arch()[0]
85+ factory.make_default_ubuntu_release_bootable(arch)
86+ mac = node.get_boot_interface().mac_address
87+ observed_config = get_config(
88+ rack_controller.system_id, local_ip, remote_ip, mac=mac)
89+ self.assertEqual("hwe-16.04", observed_config["subarch"])
90+
91+ def test__commissioning_node_uses_min_hwe_kernel_reports_missing(self):
92+ rack_controller = factory.make_RackController()
93+ local_ip = factory.make_ip_address()
94+ remote_ip = factory.make_ip_address()
95+ node = factory.make_Node_with_Interface_on_Subnet(
96+ status=NODE_STATUS.COMMISSIONING,
97+ min_hwe_kernel="hwe-x")
98+ mac = node.get_boot_interface().mac_address
99+ observed_config = get_config(
100+ rack_controller.system_id, local_ip, remote_ip, mac=mac)
101+ self.assertEqual("no-such-kernel", observed_config["subarch"])
102
103 def test__returns_ubuntu_os_series_for_ubuntu_xinstall(self):
104 distro_series = random.choice(["trusty", "vivid", "wily", "xenial"])
105
106=== modified file 'src/maasserver/utils/osystems.py'
107--- src/maasserver/utils/osystems.py 2016-09-29 19:23:13 +0000
108+++ src/maasserver/utils/osystems.py 2016-10-03 17:54:21 +0000
109@@ -357,7 +357,10 @@
110 else:
111 raise ValueError("Unknown release or kernel %s!" % string)
112
113- if parts[0] == 'hwe':
114+ # hwe kernels should only have a higher weight when using the new format
115+ # which is hwe-<version>. This ensures the old format maps to the ga
116+ # kernel.
117+ if parts[0] == 'hwe' and len(parts[1]) > 1:
118 weight += 1
119
120 if release == 'rolling':
121
122=== modified file 'src/maasserver/utils/tests/test_osystems.py'
123--- src/maasserver/utils/tests/test_osystems.py 2016-09-30 13:56:04 +0000
124+++ src/maasserver/utils/tests/test_osystems.py 2016-10-03 17:54:21 +0000
125@@ -376,7 +376,7 @@
126 }),
127 ("Old style kernel", {
128 "string": "hwe-%s" % release['series'][0],
129- "expected": version_tuple + tuple([1]),
130+ "expected": version_tuple + tuple([0]),
131 }),
132 ("GA kernel", {
133 "string": "ga-%s" % version_str,