Merge lp:~ltrager/maas/lp1654450_2.1 into lp:maas/2.1

Proposed by Lee Trager
Status: Merged
Approved by: Lee Trager
Approved revision: no longer in the source branch.
Merged at revision: 5577
Proposed branch: lp:~ltrager/maas/lp1654450_2.1
Merge into: lp:maas/2.1
Diff against target: 196 lines (+56/-19)
7 files modified
docs/changelog.rst (+1/-0)
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_2.1
Reviewer Review Type Date Requested Status
Lee Trager (community) Approve
Review via email: mp+314385@code.launchpad.net

Commit message

Backport r5629 from trunk: 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
Lee Trager (ltrager) wrote :
review: Approve

Preview Diff

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

Subscribers

People subscribed via source and target branches

to all changes: