Merge lp:~rvb/maas/bug-1456892 into lp:~maas-committers/maas/trunk

Proposed by Raphaël Badin
Status: Merged
Approved by: Raphaël Badin
Approved revision: no longer in the source branch.
Merged at revision: 3920
Proposed branch: lp:~rvb/maas/bug-1456892
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 39 lines (+18/-0)
2 files modified
src/maasserver/utils/osystems.py (+5/-0)
src/maasserver/utils/tests/test_osystems.py (+13/-0)
To merge this branch: bzr merge lp:~rvb/maas/bug-1456892
Reviewer Review Type Date Requested Status
Gavin Panella (community) Approve
Review via email: mp+259737@code.launchpad.net

Commit message

Do not break the computation of the initial distro series if the OS associated with a node isn't part of the list of supported OS.

Description of the change

This is simple defensive programming: avoid breaking when the OS associated with a node isn't part of the list of supported OSes. Note that this may be indicative of a bigger problem… and the deployment might fail but things should obviously break in get_distro_series_initial().

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

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/utils/osystems.py'
2--- src/maasserver/utils/osystems.py 2014-09-22 14:28:42 +0000
3+++ src/maasserver/utils/osystems.py 2015-05-21 09:48:44 +0000
4@@ -151,6 +151,11 @@
5 key_required = get_release_requires_key(release)
6 else:
7 key_required = ''
8+ else:
9+ # OS of the instance isn't part of the given OSes list so we can't
10+ # figure out if the key is required or not, default to not requiring
11+ # it.
12+ key_required = ''
13 if osystem_name is not None and osystem_name != '':
14 if series is None:
15 series = ''
16
17=== modified file 'src/maasserver/utils/tests/test_osystems.py'
18--- src/maasserver/utils/tests/test_osystems.py 2015-05-07 18:14:38 +0000
19+++ src/maasserver/utils/tests/test_osystems.py 2015-05-21 09:48:44 +0000
20@@ -212,6 +212,19 @@
21 get_distro_series_initial(
22 [osystem], node, with_key_required=True))
23
24+ def test_get_distro_series_initial_works_around_conflicting_os(self):
25+ # Test for bug 1456892.
26+ releases = [
27+ make_rpc_release(requires_license_key=True) for _ in range(3)]
28+ osystem = make_rpc_osystem(releases=releases)
29+ release = random.choice(releases)
30+ node = factory.make_Node(
31+ osystem=osystem['name'], distro_series=release['name'])
32+ self.assertEqual(
33+ '%s/%s' % (osystem['name'], release['name']),
34+ get_distro_series_initial(
35+ [], node, with_key_required=True))
36+
37 def test_list_commissioning_choices_returns_empty_list_if_not_ubuntu(self):
38 osystem = make_rpc_osystem()
39 self.assertEqual([], list_commissioning_choices([osystem]))