Share manager: catch exception raised by driver's setup()
If a driver raises an exception in its do_setup() or check_for_setup_error() methods the manila-share service will crash but will be automatically restarted by oslo_service.service.ProcessLauncher. So this creates a endless loop. This patch catches any exception raised by the driver setup and simply logs the exception. Change-Id: I5c4c551da9d3576ea49118ef09655d2939990cb2 Closed-Bug: #1500964
This commit is contained in:
parent
57ca688176
commit
4b87f6f40d
@ -207,8 +207,15 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||
"""Initialization for a standalone service."""
|
||||
|
||||
ctxt = context.get_admin_context()
|
||||
try:
|
||||
self.driver.do_setup(ctxt)
|
||||
self.driver.check_for_setup_error()
|
||||
except Exception:
|
||||
LOG.exception(_LE("Failed to initialize driver %s"),
|
||||
self.driver.__class__.__name__)
|
||||
# we don't want to continue since we failed
|
||||
# to initialize the driver correctly.
|
||||
return
|
||||
|
||||
share_instances = self.db.share_instances_get_all_by_host(ctxt,
|
||||
self.host)
|
||||
|
@ -137,6 +137,26 @@ class ShareManagerTestCase(test.TestCase):
|
||||
self.share_manager.driver.check_for_setup_error.\
|
||||
assert_called_once_with()
|
||||
|
||||
def test_init_host_with_driver_do_setup_fail(self):
|
||||
self.mock_object(self.share_manager.driver, 'do_setup',
|
||||
mock.Mock(side_effect=Exception()))
|
||||
self.mock_object(manager.LOG, 'exception')
|
||||
|
||||
self.share_manager.init_host()
|
||||
|
||||
manager.LOG.exception.assert_called_with(
|
||||
mock.ANY, self.share_manager.driver.__class__.__name__)
|
||||
|
||||
def test_init_host_with_driver_check_for_setup_error_fail(self):
|
||||
self.mock_object(self.share_manager.driver, 'check_for_setup_error',
|
||||
mock.Mock(side_effect=Exception()))
|
||||
self.mock_object(manager.LOG, 'exception')
|
||||
|
||||
self.share_manager.init_host()
|
||||
|
||||
manager.LOG.exception.assert_called_with(
|
||||
mock.ANY, self.share_manager.driver.__class__.__name__)
|
||||
|
||||
def _setup_init_mocks(self, setup_access_rules=True):
|
||||
instances = [
|
||||
db_utils.create_share(id='fake_id_1',
|
||||
|
Loading…
Reference in New Issue
Block a user