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
This commit is contained in:
Garrett Holmstrom 2017-03-14 14:45:05 -07:00
parent c416b9ac65
commit 7c43c8ea82
2 changed files with 51 additions and 0 deletions

View File

@ -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):

View File

@ -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 <releng@fedoraproject.org> - 0.7.9-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild