Merge lp:~lamont/maas/bug-1636251-1.9 into lp:maas/1.9

Proposed by LaMont Jones on 2016-10-24
Status: Merged
Approved by: LaMont Jones on 2016-10-25
Approved revision: 4597
Merged at revision: 4596
Proposed branch: lp:~lamont/maas/bug-1636251-1.9
Merge into: lp:maas/1.9
Diff against target: 66 lines (+20/-3)
3 files modified
docs/changelog.rst (+2/-0)
src/maasserver/preseed_network.py (+6/-1)
src/maasserver/tests/test_preseed_network.py (+12/-2)
To merge this branch: bzr merge lp:~lamont/maas/bug-1636251-1.9
Reviewer Review Type Date Requested Status
Mike Pontillo (community) 2016-10-24 Approve on 2016-10-25
Review via email: mp+309189@code.launchpad.net

Commit message

The domain for the node needs to be listed first in the search directive in resolv.conf.

Description of the change

The domain for the node needs to be listed first in the search directive in resolv.conf.

To post a comment you must log in.
Mike Pontillo (mpontillo) wrote :

Fix looks good, but I'm not quite sure how the test tests this specific fix?

review: Needs Information
Mike Pontillo (mpontillo) wrote :

Ah, I didn't realize the first argument to the NodeGroup factory was the domain name. Never mind on part of my comment, but I still wonder where in the test we make sure the node's domain comes first?

LaMont Jones (lamont) wrote :

> Ah, I didn't realize the first argument to the NodeGroup factory was the
> domain name. Never mind on part of my comment, but I still wonder where in the
> test we make sure the node's domain comes first?

collectDNSConfig in the test file generates the expected config, and has been changed to always put the domain portion of the fqdn of the node in ahead of the sorted dns search list (and pruning dupes as it goes.)

Mike Pontillo (mpontillo) wrote :

Got it. Sounds good; thanks!

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 2016-07-17 00:28:01 +0000
3+++ docs/changelog.rst 2016-10-24 23:42:39 +0000
4@@ -5,6 +5,8 @@
5 1.9.5
6 =====
7
8+LP: #1636251 [1.9] resolv.conf search path doesn't match the domain for the host.
9+
10 LP: #1603590 [1.9] MAAS does not allow link-local address for default gateway on ipv6 subnet.
11
12 1.9.4
13
14=== modified file 'src/maasserver/preseed_network.py'
15--- src/maasserver/preseed_network.py 2015-11-09 19:39:43 +0000
16+++ src/maasserver/preseed_network.py 2016-10-24 23:42:39 +0000
17@@ -58,10 +58,15 @@
18 # Order the network_config where dependencies come first.
19 self._order_config_dependency()
20
21+ domain_name = self.node.fqdn.split('.', 1)[1]
22+ search_list = [domain_name] + [
23+ name
24+ for name in sorted(get_dns_search_paths())
25+ if name != domain_name]
26 self.network_config.append({
27 "type": "nameserver",
28 "address": get_dns_server_address(nodegroup=self.node.nodegroup),
29- "search": sorted(get_dns_search_paths()),
30+ "search": search_list,
31 })
32
33 network_config = {
34
35=== modified file 'src/maasserver/tests/test_preseed_network.py'
36--- src/maasserver/tests/test_preseed_network.py 2015-11-09 19:39:43 +0000
37+++ src/maasserver/tests/test_preseed_network.py 2016-10-24 23:42:39 +0000
38@@ -213,7 +213,11 @@
39 def collectDNSConfig(self, node):
40 config = "- type: nameserver\n address: %s\n search:\n" % (
41 get_dns_server_address(nodegroup=node.nodegroup))
42- dns_searches = sorted(get_dns_search_paths())
43+ domain_name = node.fqdn.split('.', 1)[1]
44+ dns_searches = [domain_name] + [
45+ name
46+ for name in sorted(get_dns_search_paths())
47+ if name != domain_name]
48 for dns_name in dns_searches:
49 config += " - %s\n" % dns_name
50 return config
51@@ -222,8 +226,14 @@
52 class TestSimpleNetworkLayout(MAASServerTestCase, AssertNetworkConfigMixin):
53
54 def test__renders_expected_output(self):
55+ factory.make_NodeGroup(
56+ name=factory.make_name('aaa'))
57+ nodegroup = factory.make_NodeGroup(
58+ name=factory.make_name('bbb'))
59+ factory.make_NodeGroup(
60+ name=factory.make_name('ccc'))
61 node = factory.make_Node_with_Interface_on_Subnet(
62- interface_count=2)
63+ interface_count=2, nodegroup=nodegroup)
64 for iface in node.interface_set.filter(enabled=True):
65 factory.make_StaticIPAddress(
66 interface=iface,

Subscribers

People subscribed via source and target branches