init_host should be called before RPC consumer is created
This change adds a new hook to Manager class called init_host_with_rpc() to allow services like scheduler to do something once RPC is ready. Copied from cinder65fa80c361
and60c563f72d
Change-Id: Iac6507a6e395c55f0fec453650009f08c2bb6563 Closes-Bug: #1271568
This commit is contained in:
parent
4bfea794d7
commit
0339802a5d
@ -103,7 +103,19 @@ class Manager(base.Base, PeriodicTasks):
|
||||
def init_host(self):
|
||||
"""Handle initialization if this is a standalone service.
|
||||
|
||||
Child classes should override this method.
|
||||
A hook point for services to execute tasks before the services are made
|
||||
available (i.e. showing up on RPC and starting to accept RPC calls) to
|
||||
other components. Child classes should override this method.
|
||||
|
||||
"""
|
||||
pass
|
||||
|
||||
def init_host_with_rpc(self):
|
||||
"""A hook for service to do jobs after RPC is ready.
|
||||
|
||||
Like init_host(), this method is a hook where services get a chance
|
||||
to execute tasks that *need* RPC. Child classes should override
|
||||
this method.
|
||||
|
||||
"""
|
||||
pass
|
||||
|
@ -86,7 +86,7 @@ class SchedulerManager(manager.Manager):
|
||||
self.message_api = message_api.API()
|
||||
super(SchedulerManager, self).__init__(*args, **kwargs)
|
||||
|
||||
def init_host(self):
|
||||
def init_host_with_rpc(self):
|
||||
ctxt = context.get_admin_context()
|
||||
self.request_service_capabilities(ctxt)
|
||||
|
||||
|
@ -135,6 +135,7 @@ class Service(service.Service):
|
||||
LOG.info('Starting %(topic)s node (version %(version_string)s)',
|
||||
{'topic': self.topic, 'version_string': version_string})
|
||||
self.model_disconnected = False
|
||||
self.manager.init_host()
|
||||
ctxt = context.get_admin_context()
|
||||
|
||||
if self.coordinator:
|
||||
@ -156,7 +157,8 @@ class Service(service.Service):
|
||||
self.rpcserver = rpc.get_server(target, endpoints)
|
||||
self.rpcserver.start()
|
||||
|
||||
self.manager.init_host()
|
||||
self.manager.init_host_with_rpc()
|
||||
|
||||
if self.report_interval:
|
||||
pulse = loopingcall.FixedIntervalLoopingCall(self.report_state)
|
||||
pulse.start(interval=self.report_interval,
|
||||
|
@ -85,14 +85,14 @@ class SchedulerManagerTestCase(test.TestCase):
|
||||
|
||||
self.assertIsInstance(test_manager.driver, filter.FilterScheduler)
|
||||
|
||||
def test_init_host(self):
|
||||
def test_init_host_with_rpc(self):
|
||||
|
||||
self.mock_object(context,
|
||||
'get_admin_context',
|
||||
mock.Mock(return_value='fake_admin_context'))
|
||||
self.mock_object(self.manager, 'request_service_capabilities')
|
||||
|
||||
self.manager.init_host()
|
||||
self.manager.init_host_with_rpc()
|
||||
|
||||
self.manager.request_service_capabilities.assert_called_once_with(
|
||||
'fake_admin_context')
|
||||
|
@ -0,0 +1,6 @@
|
||||
---
|
||||
fixes:
|
||||
- |
|
||||
An issue with RPC handling on service restart was addressed by ensuring
|
||||
proper initialization before creating the RPC consumer. See `bug 1271568
|
||||
<https://bugs.launchpad.net/manila/+bug/1271568>`_ for more details.
|
Loading…
Reference in New Issue
Block a user