78 lines
2.9 KiB
Diff
78 lines
2.9 KiB
Diff
|
From 0dfe06ba4642fbf64c04b6a4e11400a94eb27a9f Mon Sep 17 00:00:00 2001
|
||
|
From: Major Hayden <major@mhtx.net>
|
||
|
Date: Tue, 9 May 2023 16:27:36 -0500
|
||
|
Subject: [PATCH] resolv_conf: Allow > 3 nameservers (#2152)
|
||
|
|
||
|
Systems running systemd-resolved or dnsmasq can utlize more than three
|
||
|
namervers. Older systems will just use the first three and ignore the
|
||
|
rest.
|
||
|
|
||
|
Signed-off-by: Major Hayden <major@redhat.com>
|
||
|
---
|
||
|
cloudinit/distros/parsers/resolv_conf.py | 8 --------
|
||
|
tests/unittests/distros/test_resolv.py | 12 +++++++++---
|
||
|
tools/.github-cla-signers | 1 +
|
||
|
3 files changed, 10 insertions(+), 11 deletions(-)
|
||
|
|
||
|
diff --git a/cloudinit/distros/parsers/resolv_conf.py b/cloudinit/distros/parsers/resolv_conf.py
|
||
|
index d31ffeb114..0d8dc83f5f 100644
|
||
|
--- a/cloudinit/distros/parsers/resolv_conf.py
|
||
|
+++ b/cloudinit/distros/parsers/resolv_conf.py
|
||
|
@@ -87,14 +87,6 @@ def add_nameserver(self, ns):
|
||
|
new_ns = util.uniq_list(new_ns)
|
||
|
if len(new_ns) == len(current_ns):
|
||
|
return current_ns
|
||
|
- if len(current_ns) >= 3:
|
||
|
- LOG.warning(
|
||
|
- "ignoring nameserver %r: adding would "
|
||
|
- "exceed the maximum of "
|
||
|
- "'3' name servers (see resolv.conf(5))",
|
||
|
- ns,
|
||
|
- )
|
||
|
- return current_ns[:3]
|
||
|
self._remove_option("nameserver")
|
||
|
for n in new_ns:
|
||
|
self._contents.append(("option", ["nameserver", n, ""]))
|
||
|
diff --git a/tests/unittests/distros/test_resolv.py b/tests/unittests/distros/test_resolv.py
|
||
|
index 65e7810116..363fd31db3 100644
|
||
|
--- a/tests/unittests/distros/test_resolv.py
|
||
|
+++ b/tests/unittests/distros/test_resolv.py
|
||
|
@@ -30,16 +30,22 @@ def test_local_domain(self):
|
||
|
|
||
|
def test_nameservers(self):
|
||
|
rp = resolv_conf.ResolvConf(BASE_RESOLVE)
|
||
|
+
|
||
|
+ # Start with two nameservers that already appear in the configuration.
|
||
|
self.assertIn("10.15.44.14", rp.nameservers)
|
||
|
self.assertIn("10.15.30.92", rp.nameservers)
|
||
|
+
|
||
|
+ # Add a third nameserver and verify it appears in the resolv.conf.
|
||
|
rp.add_nameserver("10.2")
|
||
|
self.assertIn("10.2", rp.nameservers)
|
||
|
self.assertIn("nameserver 10.2", str(rp))
|
||
|
- self.assertNotIn("10.3", rp.nameservers)
|
||
|
self.assertEqual(len(rp.nameservers), 3)
|
||
|
- rp.add_nameserver("10.2")
|
||
|
+
|
||
|
+ # Add a fourth nameserver and verify it appears in the resolv.conf.
|
||
|
rp.add_nameserver("10.3")
|
||
|
- self.assertNotIn("10.3", rp.nameservers)
|
||
|
+ self.assertIn("10.3", rp.nameservers)
|
||
|
+ self.assertIn("nameserver 10.3", str(rp))
|
||
|
+ self.assertEqual(len(rp.nameservers), 4)
|
||
|
|
||
|
def test_search_domains(self):
|
||
|
rp = resolv_conf.ResolvConf(BASE_RESOLVE)
|
||
|
diff --git a/tools/.github-cla-signers b/tools/.github-cla-signers
|
||
|
index 7615f0fbf4..a3d692b634 100644
|
||
|
--- a/tools/.github-cla-signers
|
||
|
+++ b/tools/.github-cla-signers
|
||
|
@@ -82,6 +82,7 @@ lucasmoura
|
||
|
lucendio
|
||
|
lungj
|
||
|
magnetikonline
|
||
|
+major
|
||
|
mal
|
||
|
mamercad
|
||
|
ManassehZhou
|