Fail if too many nameservers are provided

The nameservers are limited by neutron to the max configured servers
which is 5 by default. Since we do not offer a way to tune this value,
let's fail the user early if they are providing too many nameservers.
If a user wants to provide more than 5, they can do so by increasing the
max_dns_nameservers in neutron and setting the DnsServers via extra
environment files.

Change-Id: I51ed6f8bb109df7f9038bbf691097d50ce9e54b3
Closes-Bug: 1812919
This commit is contained in:
Alex Schultz 2019-01-22 14:33:49 -07:00
parent d5b729cd7d
commit cf026ddb20
2 changed files with 15 additions and 0 deletions

View File

@ -31,6 +31,7 @@ from oslo_config import fixture as oslo_fixture
from tripleo_common.image import kolla_builder
from tripleoclient import exceptions
from tripleoclient.tests import base
from tripleoclient.v1 import undercloud_config
@ -173,6 +174,15 @@ class TestNetworkSettings(base.TestCase):
'NetworkGateway': '192.168.24.1'}}}
self.assertEqual(expected, env)
def test_nameserver_toomany_fail(self):
env = {}
self.conf.config(undercloud_nameservers=['1.1.1.1', '1.1.1.2',
'1.1.1.3', '1.1.1.4',
'1.1.1.5', '1.1.1.6'])
self.assertRaises(exceptions.InvalidConfiguration,
undercloud_config._process_network_args,
env)
def test_start_end_all_addresses(self):
self.conf.config(dhcp_start='192.168.24.0',
dhcp_end='192.168.24.255',

View File

@ -335,6 +335,11 @@ def _process_network_args(env):
env['UndercloudCtlplaneSubnets'][subnet].update(
{param_value: s[param_key]})
env['MasqueradeNetworks'] = _generate_masquerade_networks()
if len(CONF['undercloud_nameservers']) > 5:
raise exceptions.InvalidConfiguration('Too many nameservers provided. '
'Please provide less than 6 '
'servers in undercloud_'
'nameservers.')
env['DnsServers'] = ','.join(CONF['undercloud_nameservers'])