#34 Allow > 3 nameservers to be used rhbz#2068529
Merged a year ago by mhayden. Opened a year ago by mhayden.
rpms/ mhayden/cloud-init allow-many-nameservers  into  rawhide

file modified
+5
@@ -14,6 +14,11 @@ 

  # and part of https://github.com/canonical/cloud-init/pull/2036

  Patch2:         Fedora-Enable-CA-handling.patch

  

+ # Allow > 3 nameservers to be written to /etc/resolv.conf.

+ # https://github.com/canonical/cloud-init/pull/2152

+ # https://bugzilla.redhat.com/show_bug.cgi?id=2068529

+ Patch3:         multiple-nameservers.patch

+ 

  BuildArch:      noarch

  

  BuildRequires:  pkgconfig(systemd)

@@ -0,0 +1,77 @@ 

+ 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

2 new commits added

  • Allow > 3 nameservers to be used rhbz#2068529
  • Modernize the spec
a year ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/7aaafe7b0e8548c0aacd5b0a9665a836

Okay, I'll extract the commit with the patch and get it merged in.

rebased onto 4975347

a year ago

Pull-Request has been merged by mhayden

a year ago

Build succeeded.
https://fedora.softwarefactory-project.io/zuul/buildset/f7af06929cab4558bef18637975798a5

Metadata