diff options
author | Major Hayden <major@mhtx.net> | 2023-05-09 16:27:36 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-09 16:27:36 -0500 |
commit | 0dfe06ba4642fbf64c04b6a4e11400a94eb27a9f (patch) | |
tree | e418815a3b8da97cfc01854b57571f79c6b346ed | |
parent | e07ad4a570c6588323bac0a5417167e4fd690b28 (diff) | |
download | cloud-init-git-0dfe06ba4642fbf64c04b6a4e11400a94eb27a9f.tar.gz |
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>
-rw-r--r-- | cloudinit/distros/parsers/resolv_conf.py | 8 | ||||
-rw-r--r-- | tests/unittests/distros/test_resolv.py | 12 | ||||
-rw-r--r-- | 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 d31ffeb1..0d8dc83f 100644 --- a/cloudinit/distros/parsers/resolv_conf.py +++ b/cloudinit/distros/parsers/resolv_conf.py @@ -87,14 +87,6 @@ class ResolvConf: 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 65e78101..363fd31d 100644 --- a/tests/unittests/distros/test_resolv.py +++ b/tests/unittests/distros/test_resolv.py @@ -30,16 +30,22 @@ class TestResolvHelper(TestCase): 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 7615f0fb..a3d692b6 100644 --- a/tools/.github-cla-signers +++ b/tools/.github-cla-signers @@ -82,6 +82,7 @@ lucasmoura lucendio lungj magnetikonline +major mal mamercad ManassehZhou |