Merge "Make "enabled_drivers" config option more resilient to failures"

This commit is contained in:
Jenkins 2016-12-07 17:51:15 +00:00 committed by Gerrit Code Review
commit 644f02fd87
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.