Merge lp:~ltrager/maas/lp1654450 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: 5629
Proposed branch: lp:~ltrager/maas/lp1654450
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 184 lines (+55/-19)
6 files modified
src/maasserver/models/bootresource.py (+28/-5)
src/maasserver/models/tests/test_bootresource.py (+16/-1)
src/maasserver/tests/test_forms_commissioning.py (+4/-4)
src/maasserver/utils/osystems.py (+4/-6)
src/maasserver/utils/tests/test_osystems.py (+1/-1)
src/maasserver/websockets/handlers/general.py (+2/-2)
To merge this branch: bzr merge lp:~ltrager/maas/lp1654450
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+314195@code.launchpad.net

Commit message

Only include real kernels when listing all usable kernels.

Each kernel lists all the other kernels supported in that release. For example hwe-16.04 lists hwe-{p,q,r,s,t,u,v,w} as it contains the support proved by all of those kernels. MAAS was filtering out the older versions however edge kernels also display the next kernel as they are a preview release.

To post a comment you must log in.
Revision history for this message
Gavin Panella (allenap) wrote :

Looks good, but read my comments before landing.

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

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

Get:1 http://security.ubuntu.com/ubuntu xenial-security InRelease [102 kB]
Hit:2 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial InRelease
Get:3 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-updates InRelease [102 kB]
Get:4 http://prodstack-zone-2.clouds.archive.ubuntu.com/ubuntu xenial-backports InRelease [102 kB]
Fetched 306 kB in 0s (612 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 libnss-wrapper 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...
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).
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.18-1).
python-netifaces is already the newest version (0.10.4-0.1build2).
python-psycopg2 is a...

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/models/bootresource.py'
2--- src/maasserver/models/bootresource.py 2016-10-12 15:26:17 +0000
3+++ src/maasserver/models/bootresource.py 2017-01-10 01:10:50 +0000
4@@ -1,4 +1,4 @@
5-# Copyright 2014-2016 Canonical Ltd. This software is licensed under the
6+# Copyright 2014-2017 Canonical Ltd. This software is licensed under the
7 # GNU Affero General Public License version 3 (see the file LICENSE).
8
9 """Boot Resource."""
10@@ -230,9 +230,10 @@
11 return False
12 return True
13
14- def get_usable_hwe_kernels(
15- self, name=None, architecture=None, kflavor=None):
16- """Return the set of usable kernels for architecture and release."""
17+ def get_hwe_kernels(
18+ self, name=None, architecture=None, kflavor=None,
19+ include_subarches=False):
20+ """Return the set of kernels."""
21 from maasserver.utils.osystems import get_release_version_from_string
22
23 if not name:
24@@ -257,7 +258,7 @@
25 subarch_parts[1] = 'rolling'
26 kernels.add('-'.join(subarch_parts))
27
28- if "subarches" in resource.extra:
29+ if include_subarches and "subarches" in resource.extra:
30 for subarch in resource.extra["subarches"].split(","):
31 if subarch.startswith("hwe-") or subarch.startswith("ga-"):
32 if kflavor is None:
33@@ -277,6 +278,28 @@
34 return sorted(
35 kernels, key=lambda k: get_release_version_from_string(k))
36
37+ def get_usable_hwe_kernels(
38+ self, name=None, architecture=None, kflavor=None):
39+ """Return the set of usable kernels for the given name, arch, kflavor.
40+
41+ Returns only the list of kernels which MAAS has downloaded. For example
42+ if Trusty and Xenial have been downloaded this will return hwe-t,
43+ ga-16.04, hwe-16.04, hwe-16.04-edge, hwe-16.04-lowlatency, and
44+ hwe-16.04-lowlatency-edge."""
45+ return self.get_hwe_kernels(name, architecture, kflavor, False)
46+
47+ def get_supported_hwe_kernels(
48+ self, name=None, architecture=None, kflavor=None):
49+ """Return the set of supported kernels for the given name, arch,
50+ kflavor.
51+
52+ Returns the list of kernels downloaded by MAAS and the subarches each
53+ of those kernels support. For example if Trusty and Xenial have been
54+ downloaded this will return hwe-p, hwe-q, hwe-r, hwe-s, hwe-t, hwe-u,
55+ hwe-v, hwe-w, ga-16.04, hwe-16.04, hwe-16.04-edge,
56+ hwe-16.04-lowlatency, and hwe-16.04-lowlatency-edge."""
57+ return self.get_hwe_kernels(name, architecture, kflavor, True)
58+
59 def get_kpackage_for_node(self, node):
60 """Return the kernel package name for the kernel specified."""
61 if not node.hwe_kernel:
62
63=== modified file 'src/maasserver/models/tests/test_bootresource.py'
64--- src/maasserver/models/tests/test_bootresource.py 2016-10-12 15:26:17 +0000
65+++ src/maasserver/models/tests/test_bootresource.py 2017-01-10 01:10:50 +0000
66@@ -1,4 +1,4 @@
67-# Copyright 2014-2016 Canonical Ltd. This software is licensed under the
68+# Copyright 2014-2017 Canonical Ltd. This software is licensed under the
69 # GNU Affero General Public License version 3 (see the file LICENSE).
70
71 """Tests for `BootResource`."""
72@@ -174,6 +174,21 @@
73 self.assertItemsEqual(
74 arches, usable_arches)
75
76+ def test_get_usable_hwe_kernel_doesnt_include_all_subarches(self):
77+ factory.make_usable_boot_resource(
78+ architecture='amd64/hwe-16.04',
79+ extra={'subarches': 'hwe-p,hwe-t,hwe-16.04,hwe-16.10'})
80+ self.assertEquals(
81+ ['hwe-16.04'], BootResource.objects.get_usable_hwe_kernels())
82+
83+ def test_get_supported_hwe_kernel_includes_all_subarches(self):
84+ factory.make_usable_boot_resource(
85+ architecture='amd64/hwe-16.04',
86+ extra={'subarches': 'hwe-p,hwe-t,hwe-16.04,hwe-16.10'})
87+ self.assertEquals(
88+ ['hwe-p', 'hwe-t', 'hwe-16.04', 'hwe-16.10'],
89+ BootResource.objects.get_supported_hwe_kernels())
90+
91 def test_get_commissionable_resource_returns_iterable(self):
92 os = factory.make_name('os')
93 series = factory.make_name('series')
94
95=== modified file 'src/maasserver/tests/test_forms_commissioning.py'
96--- src/maasserver/tests/test_forms_commissioning.py 2016-07-30 01:17:54 +0000
97+++ src/maasserver/tests/test_forms_commissioning.py 2017-01-10 01:10:50 +0000
98@@ -40,18 +40,18 @@
99
100 def test_commissioningform_contains_real_and_ui_choice(self):
101 release = factory.pick_ubuntu_release()
102- name = "ubuntu/" + release
103+ name = 'ubuntu/%s' % release
104+ arch = factory.make_name('arch')
105 kernel = 'hwe-' + release[0]
106 # Disable boot sources signals otherwise the test fails due to unrun
107 # post-commit tasks at the end of the test.
108- self.useFixture(SignalsDisabled("bootsources"))
109+ self.useFixture(SignalsDisabled('bootsources'))
110 factory.make_BootSourceCache(
111 os=name,
112 subarch=kernel,
113 release=release)
114 factory.make_usable_boot_resource(
115- name=name,
116- extra={'subarches': kernel},
117+ name=name, architecture='%s/%s' % (arch, kernel),
118 rtype=BOOT_RESOURCE_TYPE.SYNCED)
119 Config.objects.set_config(
120 'commissioning_distro_series',
121
122=== modified file 'src/maasserver/utils/osystems.py'
123--- src/maasserver/utils/osystems.py 2016-10-03 16:27:26 +0000
124+++ src/maasserver/utils/osystems.py 2017-01-10 01:10:50 +0000
125@@ -1,4 +1,4 @@
126-# Copyright 2014-2016 Canonical Ltd. This software is licensed under the
127+# Copyright 2014-2017 Canonical Ltd. This software is licensed under the
128 # GNU Affero General Public License version 3 (see the file LICENSE).
129 """Utilities for working with operating systems."""
130
131@@ -78,10 +78,8 @@
132 for release in osystems:
133 os_release = osystem + '/' + release['name']
134 kernels[osystem][release['name']] = list_hwe_kernel_choices(
135- sorted([
136- i for i in BootResource.objects.get_usable_hwe_kernels(
137- os_release)
138- if release_a_newer_than_b(i, release['name'])]))
139+ sorted(BootResource.objects.get_usable_hwe_kernels(os_release))
140+ )
141 return kernels
142
143
144@@ -473,7 +471,7 @@
145 """Check that the min_hwe_kernel is avalible."""
146 if not min_hwe_kernel or min_hwe_kernel == "":
147 return ""
148- usable_kernels = BootResource.objects.get_usable_hwe_kernels()
149+ usable_kernels = BootResource.objects.get_supported_hwe_kernels()
150 if min_hwe_kernel not in usable_kernels:
151 raise ValidationError('%s is not a usable kernel.' % min_hwe_kernel)
152 else:
153
154=== modified file 'src/maasserver/utils/tests/test_osystems.py'
155--- src/maasserver/utils/tests/test_osystems.py 2016-10-03 16:27:26 +0000
156+++ src/maasserver/utils/tests/test_osystems.py 2017-01-10 01:10:50 +0000
157@@ -588,7 +588,7 @@
158 kernel = factory.make_kernel_string(generic_only=True)
159 self.patch(
160 BootResource.objects,
161- 'get_usable_hwe_kernels').return_value = (kernel,)
162+ 'get_supported_hwe_kernels').return_value = (kernel,)
163 self.assertEquals(kernel, validate_min_hwe_kernel(kernel))
164
165 def test_returns_empty_string_when_none(self):
166
167=== modified file 'src/maasserver/websockets/handlers/general.py'
168--- src/maasserver/websockets/handlers/general.py 2016-12-12 22:07:14 +0000
169+++ src/maasserver/websockets/handlers/general.py 2017-01-10 01:10:50 +0000
170@@ -1,4 +1,4 @@
171-# Copyright 2015-2016 Canonical Ltd. This software is licensed under the
172+# Copyright 2015-2017 Canonical Ltd. This software is licensed under the
173 # GNU Affero General Public License version 3 (see the file LICENSE).
174
175 """The general handler for the WebSocket connection."""
176@@ -86,7 +86,7 @@
177 the flavor during deployment.
178 """
179 return list_hwe_kernel_choices(
180- BootResource.objects.get_usable_hwe_kernels()
181+ BootResource.objects.get_supported_hwe_kernels()
182 )
183
184 def default_min_hwe_kernel(self, params):