Check hooks availability on start-up
Otherwise we fail in the middle of processing. Change-Id: I2d44fc03111bdeeea93c8d95f8441ce1b81cf235 Closes-Bug: #1418005
This commit is contained in:
parent
6eec990919
commit
17beef7990
|
@ -23,12 +23,13 @@ import flask
|
|||
from oslo_config import cfg
|
||||
from oslo_utils import uuidutils
|
||||
|
||||
from ironic_discoverd.common.i18n import _, _LE, _LW
|
||||
from ironic_discoverd.common.i18n import _, _LC, _LE, _LI, _LW
|
||||
# Import configuration options
|
||||
from ironic_discoverd import conf # noqa
|
||||
from ironic_discoverd import firewall
|
||||
from ironic_discoverd import introspect
|
||||
from ironic_discoverd import node_cache
|
||||
from ironic_discoverd.plugins import base as plugins_base
|
||||
from ironic_discoverd import process
|
||||
from ironic_discoverd import utils
|
||||
|
||||
|
@ -163,6 +164,15 @@ def init():
|
|||
node_cache.init()
|
||||
check_ironic_available()
|
||||
|
||||
try:
|
||||
hooks = [ext.name for ext in plugins_base.processing_hooks_manager()]
|
||||
except KeyError as exc:
|
||||
# stevedore raises KeyError on missing hook
|
||||
LOG.critical(_LC('Hook %s failed to load or was not found'), str(exc))
|
||||
sys.exit(1)
|
||||
|
||||
LOG.info(_LI('Enabled processing hooks: %s'), hooks)
|
||||
|
||||
if CONF.discoverd.manage_firewall:
|
||||
firewall.init()
|
||||
period = CONF.discoverd.firewall_update_period
|
||||
|
|
|
@ -244,3 +244,13 @@ class TestInit(test_base.BaseTest):
|
|||
for (args, call) in zip(spawn_n_expected_args,
|
||||
spawn_n_call_args_list):
|
||||
self.assertEqual(args, call[0])
|
||||
|
||||
@mock.patch.object(main.LOG, 'critical')
|
||||
def test_init_failed_processing_hook(self, mock_log, mock_node_cache,
|
||||
mock_get_client, mock_auth,
|
||||
mock_firewall, mock_spawn_n):
|
||||
CONF.set_override('processing_hooks', 'foo!', 'discoverd')
|
||||
plugins_base._HOOKS_MGR = None
|
||||
|
||||
self.assertRaises(SystemExit, main.init)
|
||||
mock_log.assert_called_once_with(mock.ANY, "'foo!'")
|
||||
|
|
Loading…
Reference in New Issue