Merge lp:~julian-edwards/maas/remove-harmless-warning-bug-1386909 into lp:~maas-committers/maas/trunk

Proposed by Julian Edwards
Status: Merged
Approved by: Julian Edwards
Approved revision: no longer in the source branch.
Merged at revision: 3339
Proposed branch: lp:~julian-edwards/maas/remove-harmless-warning-bug-1386909
Merge into: lp:~maas-committers/maas/trunk
Diff against target: 57 lines (+22/-1)
2 files modified
src/maasserver/api/pxeconfig.py (+7/-0)
src/maasserver/api/tests/test_pxeconfig.py (+15/-1)
To merge this branch: bzr merge lp:~julian-edwards/maas/remove-harmless-warning-bug-1386909
Reviewer Review Type Date Requested Status
Graham Binns (community) Approve
Newell Jensen (community) Approve
Review via email: mp+240809@code.launchpad.net

Commit message

Don't bother searching for a boot purpose of "local" when serving pxeconfig API requests. It saves a call to the cluster controller and prevents a spurious log message.

To post a comment you must log in.
Revision history for this message
Newell Jensen (newell-jensen) wrote :

Nicely done.

review: Approve
Revision history for this message
Graham Binns (gmb) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/maasserver/api/pxeconfig.py'
2--- src/maasserver/api/pxeconfig.py 2014-10-20 20:32:00 +0000
3+++ src/maasserver/api/pxeconfig.py 2014-11-06 06:13:51 +0000
4@@ -84,6 +84,13 @@
5 nodegroup, osystem, architecture, subarchitecture, series, purpose):
6 """Obtain the first available boot image for this cluster for the given
7 osystem, architecture, subarchitecute, series, and purpose."""
8+ # When local booting a node we put it through a PXE cycle. In
9+ # this case it requests a purpose of "local" when looking for
10+ # boot images. To avoid unnecessary work, we can shortcut that
11+ # here and just return None right away.
12+ if purpose == "local":
13+ return None
14+
15 try:
16 images = get_boot_images_for(
17 nodegroup, osystem, architecture, subarchitecture, series)
18
19=== modified file 'src/maasserver/api/tests/test_pxeconfig.py'
20--- src/maasserver/api/tests/test_pxeconfig.py 2014-10-20 20:32:00 +0000
21+++ src/maasserver/api/tests/test_pxeconfig.py 2014-11-06 06:13:51 +0000
22@@ -50,7 +50,10 @@
23 from maasserver.testing.orm import reload_object
24 from maasserver.testing.testcase import MAASServerTestCase
25 from maastesting.fakemethod import FakeMethod
26-from maastesting.matchers import MockCalledOnceWith
27+from maastesting.matchers import (
28+ MockCalledOnceWith,
29+ MockNotCalled,
30+ )
31 from mock import sentinel
32 from netaddr import IPNetwork
33 from provisioningserver import kernel_opts
34@@ -60,6 +63,7 @@
35 Contains,
36 ContainsAll,
37 Equals,
38+ Is,
39 MatchesListwise,
40 StartsWith,
41 )
42@@ -119,6 +123,16 @@
43 sentinel.architecture, subarch,
44 sentinel.series, purpose))
45
46+ def test__returns_None_immediately_if_purpose_is_local(self):
47+ self.patch(pxeconfig_module, 'get_boot_images_for')
48+ self.expectThat(
49+ get_boot_image(
50+ sentinel.nodegroup, sentinel.osystem,
51+ sentinel.architecture, sentinel.subarchitecture,
52+ sentinel.series, "local"),
53+ Is(None))
54+ self.expectThat(pxeconfig_module.get_boot_images_for, MockNotCalled())
55+
56
57 class TestPXEConfigAPI(MAASServerTestCase):
58