]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commitdiff
dhcp: Default to using local DNS resolution
authorKyle Mestery <mestery@mestery.com>
Wed, 17 Jun 2015 14:46:47 +0000 (14:46 +0000)
committerKyle Mestery <mestery@mestery.com>
Wed, 30 Dec 2015 18:06:16 +0000 (12:06 -0600)
It's pointless to not include default DNS resolution for Neutron.
This adds a new config option (dnsmasq_local_resolv) which defaults
to 'True' and will allow for DNS name resolution to work out of
the box. The caveat is that if the 'dnsmasq_dns_servers' is set it
will override the 'dnsmasq_local_resolv' setting, thus allowing
operators to explicitly set their own DNS servers.

DocImpact: Default to using local DNS resolution with the DHCP agent.

Change-Id: I17a884f467d307432a06f67a9dd93ed2fa6081a3
Closes-Bug: #1466117
Signed-off-by: Kyle Mestery <mestery@mestery.com>
neutron/agent/dhcp/config.py
neutron/agent/linux/dhcp.py
neutron/tests/unit/agent/linux/test_dhcp.py
releasenotes/notes/default-local-dns-a1c3fa1451f228fa.yaml [new file with mode: 0644]

index 926e8ec8f6019700c88f79bc0dd5ee6bc9dfe947..ab0d9b7263a9d4628c5db381d455143dd057374c 100644 (file)
@@ -85,6 +85,13 @@ DNSMASQ_OPTS = [
                       "The log contains DHCP and DNS log information and "
                       "is useful for debugging issues with either DHCP or "
                       "DNS. If this section is null, disable dnsmasq log.")),
+    cfg.BoolOpt('dnsmasq_local_resolv', default=True,
+                help=_("Enables the dnsmasq service to provide name "
+                       "resolution for instances via DNS resolvers on the "
+                       "host running the DHCP agent. Effectively removes the "
+                       "'--no-resolv' option from the dnsmasq process "
+                       "arguments. Adding custom DNS resolvers to the "
+                       "'dnsmasq_dns_servers' option disables this feature.")),
     cfg.IntOpt(
         'dnsmasq_lease_max',
         default=(2 ** 24),
index ff44a8e2310fe8e5269b0d8ff2562125a39363b9..4ccb7f6593ba9ca578915294689e1c780379a14c 100644 (file)
@@ -307,7 +307,6 @@ class Dnsmasq(DhcpLocalProcess):
         cmd = [
             'dnsmasq',
             '--no-hosts',
-            '--no-resolv',
             '--strict-order',
             '--except-interface=lo',
             '--pid-file=%s' % pid_file,
@@ -384,6 +383,11 @@ class Dnsmasq(DhcpLocalProcess):
             cmd.extend(
                 '--server=%s' % server
                 for server in self.conf.dnsmasq_dns_servers)
+        else:
+            # We only look at 'dnsmasq_local_resolv' if 'dnsmasq_dns_servers'
+            # is not set, which explicitly overrides 'dnsmasq_local_resolv'.
+            if not self.conf.dnsmasq_local_resolv:
+                cmd.append('--no-resolv')
 
         if self.conf.dhcp_domain:
             cmd.append('--domain=%s' % self.conf.dhcp_domain)
index 2fce527f59d7e404e5104d29bf17058ed75c2210..fe4016dc20390d736b8a8251b13aaa4b1a2f95f6 100644 (file)
@@ -1000,7 +1000,6 @@ class TestDnsmasq(TestBase):
         expected = [
             'dnsmasq',
             '--no-hosts',
-            '--no-resolv',
             '--strict-order',
             '--except-interface=lo',
             '--pid-file=%s' % expected_pid_file,
@@ -1129,6 +1128,12 @@ class TestDnsmasq(TestBase):
                           ('--log-facility=%s' % dhcp_dns_log)],
                          network)
 
+    def test_spawn_cfg_no_local_resolv(self):
+        self.conf.set_override('dnsmasq_local_resolv', False)
+
+        self._test_spawn(['--conf-file=', '--no-resolv',
+                          '--domain=openstacklocal'])
+
     def test_spawn_max_leases_is_smaller_than_cap(self):
         self._test_spawn(
             ['--conf-file=', '--domain=openstacklocal'],
diff --git a/releasenotes/notes/default-local-dns-a1c3fa1451f228fa.yaml b/releasenotes/notes/default-local-dns-a1c3fa1451f228fa.yaml
new file mode 100644 (file)
index 0000000..0c77e96
--- /dev/null
@@ -0,0 +1,14 @@
+---
+fixes:
+  - Prior to Mitaka, neither specifying DNS resolvers via the
+    'dnsmasq_dns_servers' option in the DHCP agent configuration file nor via
+    neutron subnet options causes the dnsmasq service to offer the IP address
+    on which it resides to instances for name resolution. However, the static
+    dnsmasq '--no-resolv' process argument prevents name resolution via dnsmasq
+    leaving instances without name resolution. In Mitaka+, the
+    'dnsmasq_local_resolv' option in the DHCP agent configuration file enables
+    (by default) the dnsmasq service to provide name resolution for instances
+    via DNS resolvers on the host running the DHCP agent by effectively
+    removing the '--no-resolv' option from the dnsmasq process arguments.
+    Adding custom DNS resolvers to the 'dnsmasq_dns_servers' option in the DHCP
+    agent configuration file disables this feature.