From 7c43c8ea8266aaa1b553ee6d475feb5a54985999 Mon Sep 17 00:00:00 2001 From: Garrett Holmstrom Date: Mar 14 2017 21:48:59 +0000 Subject: Make > 3 name servers a warning, not a fatal error This is useful when both IPv4 and IPv6 name servers are present. https://bugs.launchpad.net/cloud-init/+bug/1670052 https://git.launchpad.net/cloud-init/commit/?id=657fd40f9ee692a817ec4614cd0d6cb0539ffabf --- diff --git a/cloud-init-0.7.9-gt3-nameservers.patch b/cloud-init-0.7.9-gt3-nameservers.patch new file mode 100644 index 0000000..3fb7d5d --- /dev/null +++ b/cloud-init-0.7.9-gt3-nameservers.patch @@ -0,0 +1,44 @@ +Index: cloud-init-0.7.9/cloudinit/distros/parsers/resolv_conf.py +=================================================================== +--- cloud-init-0.7.9.orig/cloudinit/distros/parsers/resolv_conf.py ++++ cloud-init-0.7.9/cloudinit/distros/parsers/resolv_conf.py +@@ -6,9 +6,11 @@ + + from six import StringIO + ++from cloudinit.distros.parsers import chop_comment ++from cloudinit import log as logging + from cloudinit import util + +-from cloudinit.distros.parsers import chop_comment ++LOG = logging.getLogger(__name__) + + + # See: man resolv.conf +@@ -79,9 +81,10 @@ class ResolvConf(object): + if len(new_ns) == len(current_ns): + return current_ns + if len(current_ns) >= 3: +- # Hard restriction on only 3 name servers +- raise ValueError(("Adding %r would go beyond the " +- "'3' maximum name servers") % (ns)) ++ LOG.warn("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, ''])) +Index: cloud-init-0.7.9/tests/unittests/test_distros/test_resolv.py +=================================================================== +--- cloud-init-0.7.9.orig/tests/unittests/test_distros/test_resolv.py ++++ cloud-init-0.7.9/tests/unittests/test_distros/test_resolv.py +@@ -46,7 +46,7 @@ class TestResolvHelper(TestCase): + self.assertNotIn('10.3', rp.nameservers) + self.assertEqual(len(rp.nameservers), 3) + rp.add_nameserver('10.2') +- self.assertRaises(ValueError, rp.add_nameserver, '10.3') ++ rp.add_nameserver('10.3') + self.assertNotIn('10.3', rp.nameservers) + + def test_search_domains(self): diff --git a/cloud-init.spec b/cloud-init.spec index 3250d39..da18c56 100644 --- a/cloud-init.spec +++ b/cloud-init.spec @@ -55,6 +55,12 @@ Patch14: cloud-init-0.7.9-systemd-cloud-final.patch # https://git.launchpad.net/cloud-init/commit/?id=f81d6c7bde2af206d449de593b35773068270c84 Patch15: cloud-init-0.7.9-sysconfig-iface.patch +# Make > 3 name servers a warning, not a fatal error +# This is useful when both IPv4 and IPv6 name servers are present. +# https://bugs.launchpad.net/cloud-init/+bug/1670052 +# https://git.launchpad.net/cloud-init/commit/?id=657fd40f9ee692a817ec4614cd0d6cb0539ffabf +Patch16: cloud-init-0.7.9-gt3-nameservers.patch + BuildArch: noarch BuildRequires: pkgconfig(systemd) @@ -195,6 +201,7 @@ nosetests-%{python3_version} tests/unittests/ \ - Fixed systemd dependency cycle with cloud-final and os-collect-config [RH:1420946, RH:1428492] - Fixed systemd dependency cycle with cloud-init and multi-user.target [RH:1428492, RH:1430511] - Fixed errors in network sysconfig handling [RH:1389530, LP:1665441] +- Made > 3 name servers a warning, not a fatal error, unbreaking IPv6 setups [LP:1670052] * Fri Feb 10 2017 Fedora Release Engineering - 0.7.9-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild