Commit 525021e0 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[2964] make sure to catch exception from DataSrcClientsMgr.reconfigure.

parent e51d6fd3
......@@ -251,9 +251,19 @@ class MockDataSrcClientsMgr():
# Default faked result of find(), customizable by tests
self.found_datasrc_client = MockDataSourceClient()
self.reconfigure_param = [] # for inspection
def get_client_list(self, rrclass):
return self.found_datasrc_client_list
def reconfigure(self, arg1):
# the only current test simply needs to know this is called with
# the expected argument and exceptions are handled. if we need more
# variations in tests, this mock method should be extended.
self.reconfigure_param.append(arg1)
raise isc.server_common.datasrc_clients_mgr.ConfigError(
'reconfigure failure')
def find(self, zone_name, want_exact_match, want_finder):
"""Pretending find method on the object returned by get_clinet_list"""
if issubclass(type(self.found_datasrc_client), Exception):
......@@ -3037,6 +3047,15 @@ class TestXfrin(unittest.TestCase):
self.assertEqual(ZoneInfo.REQUEST_IXFR_DISABLED,
self.xfr.xfrin_started_request_ixfr)
def test_datasrc_config_handler(self):
"""Check datasrc config handler works expectedly."""
# This is a simple wrapper of DataSrcClientsMgr.reconfigure(), so
# we just check it's called as expected, and the only possible
# exception doesn't cause disruption.
self.xfr._datasrc_config_handler(True, False)
self.assertEqual([True],
self.xfr._datasrc_clients_mgr.reconfigure_param)
def raise_interrupt():
raise KeyboardInterrupt()
......
......@@ -1391,6 +1391,9 @@ class Xfrin:
self._cc_setup()
config_data = self._module_cc.get_full_config()
self.config_handler(config_data)
# data_sources configuration should be ready with cfgmgr, so this
# shouldn't fail; if it ever does we simply propagate the exception
# to terminate the program.
self._module_cc.add_remote_config_by_name('data_sources',
self._datasrc_config_handler)
init_keyring(self._module_cc)
......@@ -1463,7 +1466,19 @@ class Xfrin:
self._set_db_file()
def _datasrc_config_handler(self, new_config, config_data):
self._datasrc_clients_mgr.reconfigure(new_config)
"""Configuration handler of the 'data_sources' module.
The actual handling is deletegated to the DataSrcClientsMgr class;
this method is a simple wrapper.
This is essentially private, but implemented as 'private' so tests
can refer to it; other external use is prohibited.
"""
try:
self._datasrc_clients_mgr.reconfigure(new_config)
except isc.server_common.datasrc_clients_mgr.ConfigError as ex:
logger.error(XFRIN_DATASRC_CONFIG_ERROR, ex)
def shutdown(self):
''' shutdown the xfrin process. the thread which is doing xfrin should be
......
......@@ -60,6 +60,16 @@ error is given in the log message.
There was an error opening a connection to the master. The error is
shown in the log message.
% XFRIN_DATASRC_CONFIG_ERROR failed to update data source configuration: %1
Configuration for the global data sources is updated, but the update
cannot be applied to xfrin. The xfrin module will still keep running
with the previous configuration, but the cause of the failure and
other log messages must be carefully examined because if only xfrin
rejects the new configuration then the entire BIND 10 system will have
inconsistent state among different modules. If other modules accept
the update but xfrin produces this error, the xfrin module should
probably be restarted.
% XFRIN_EXITING exiting
The xfrin daemon is exiting.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment