Make "enabled_drivers" config option more resilient to failures

Do not fail to start the ironic-conductor service if there's a
trailing comma or an empty value as part of the "enabled_drivers" or
"enabled_network_interfaces" configuration option, instead, log a warning
alerting the operation of the wrong syntax.

Change-Id: Id9141c014263de5e72641613d970fd481a6aaa74
Closes-Bug: #1647783
This commit is contained in:
Lucas Alvares Gomes 2016-12-06 16:20:48 +00:00
parent d69a3b6c58
commit a581c1eafc
3 changed files with 21 additions and 0 deletions

View File

@ -182,6 +182,13 @@ class BaseDriverFactory(object):
duplicated_drivers = []
cls._enabled_driver_list = []
for item, cnt in counter:
if not item:
LOG.warning(
_LW('An empty driver was specified in the "%s" '
'configuration option and will be ignored. Please '
'fix your ironic.conf file to avoid this warning '
'message.'), cls._enabled_driver_list_config_option)
continue
if cnt > 1:
duplicated_drivers.append(item)
cls._enabled_driver_list.append(item)

View File

@ -71,6 +71,14 @@ class DriverLoadTestCase(base.TestCase):
['fake'], driver_factory.DriverFactory._extension_manager.names())
self.assertTrue(mock_log.called)
@mock.patch.object(driver_factory.LOG, 'warning', autospec=True)
def test_driver_empty_entry(self, mock_log):
self.config(enabled_drivers=['fake', ''])
driver_factory.DriverFactory._init_extension_manager()
self.assertEqual(
['fake'], driver_factory.DriverFactory._extension_manager.names())
self.assertTrue(mock_log.called)
@mock.patch.object(driver_factory, '_warn_if_unsupported')
def test_driver_init_checks_unsupported(self, mock_warn):
self.config(enabled_drivers=['fake'])

View File

@ -0,0 +1,6 @@
---
fixes:
- Fixes an issue where the ironic-conductor service would not
run if a trailing comma or empty driver was specified in the
``[DEFAULT]enabled_drivers`` configuration option. The service now
runs and logs a warning.