Handle waiting for conductor in nova.service.
Previously we were waiting for conductor to respond to a ping() in the compute manager. This patch moves this down to the base Service class. A nova service binary can indicate that db access is not allowed and if so, as soon as the service gets created, it will block while waiting for conductor to respond. The compute service has been updated to use this. This should not result in any real functional difference. The reason for this is that there is some database access that needs to be avoided down at this level. This allows us to divert these actions to conductor if needed. Part of bp no-db-compute. Change-Id: Idd6387b9428e3f9f4e4dbfe51293693238b2daf0
This commit is contained in:
parent
7258b2aa1c
commit
b189f2a67d
@ -55,6 +55,7 @@ if __name__ == '__main__':
|
|||||||
logging.setup('nova')
|
logging.setup('nova')
|
||||||
utils.monkey_patch()
|
utils.monkey_patch()
|
||||||
server = service.Service.create(binary='nova-compute',
|
server = service.Service.create(binary='nova-compute',
|
||||||
topic=CONF.compute_topic)
|
topic=CONF.compute_topic,
|
||||||
|
db_allowed=False)
|
||||||
service.serve(server)
|
service.serve(server)
|
||||||
service.wait()
|
service.wait()
|
||||||
|
@ -30,6 +30,7 @@ import time
|
|||||||
import eventlet
|
import eventlet
|
||||||
import greenlet
|
import greenlet
|
||||||
|
|
||||||
|
from nova import conductor
|
||||||
from nova import context
|
from nova import context
|
||||||
from nova import db
|
from nova import db
|
||||||
from nova import exception
|
from nova import exception
|
||||||
@ -38,6 +39,7 @@ from nova.openstack.common import eventlet_backdoor
|
|||||||
from nova.openstack.common import importutils
|
from nova.openstack.common import importutils
|
||||||
from nova.openstack.common import log as logging
|
from nova.openstack.common import log as logging
|
||||||
from nova.openstack.common import rpc
|
from nova.openstack.common import rpc
|
||||||
|
from nova.openstack.common.rpc import common as rpc_common
|
||||||
from nova import servicegroup
|
from nova import servicegroup
|
||||||
from nova import utils
|
from nova import utils
|
||||||
from nova import version
|
from nova import version
|
||||||
@ -392,7 +394,7 @@ class Service(object):
|
|||||||
|
|
||||||
def __init__(self, host, binary, topic, manager, report_interval=None,
|
def __init__(self, host, binary, topic, manager, report_interval=None,
|
||||||
periodic_enable=None, periodic_fuzzy_delay=None,
|
periodic_enable=None, periodic_fuzzy_delay=None,
|
||||||
periodic_interval_max=None,
|
periodic_interval_max=None, db_allowed=True,
|
||||||
*args, **kwargs):
|
*args, **kwargs):
|
||||||
self.host = host
|
self.host = host
|
||||||
self.binary = binary
|
self.binary = binary
|
||||||
@ -407,6 +409,9 @@ class Service(object):
|
|||||||
self.saved_args, self.saved_kwargs = args, kwargs
|
self.saved_args, self.saved_kwargs = args, kwargs
|
||||||
self.timers = []
|
self.timers = []
|
||||||
self.backdoor_port = None
|
self.backdoor_port = None
|
||||||
|
self.db_allowed = db_allowed
|
||||||
|
self.conductor_api = conductor.API(use_local=db_allowed)
|
||||||
|
self.conductor_api.wait_until_ready(context.get_admin_context())
|
||||||
self.servicegroup_api = servicegroup.API()
|
self.servicegroup_api = servicegroup.API()
|
||||||
|
|
||||||
def start(self):
|
def start(self):
|
||||||
@ -481,7 +486,8 @@ class Service(object):
|
|||||||
@classmethod
|
@classmethod
|
||||||
def create(cls, host=None, binary=None, topic=None, manager=None,
|
def create(cls, host=None, binary=None, topic=None, manager=None,
|
||||||
report_interval=None, periodic_enable=None,
|
report_interval=None, periodic_enable=None,
|
||||||
periodic_fuzzy_delay=None, periodic_interval_max=None):
|
periodic_fuzzy_delay=None, periodic_interval_max=None,
|
||||||
|
db_allowed=True):
|
||||||
"""Instantiates class and passes back application object.
|
"""Instantiates class and passes back application object.
|
||||||
|
|
||||||
:param host: defaults to CONF.host
|
:param host: defaults to CONF.host
|
||||||
@ -514,7 +520,8 @@ class Service(object):
|
|||||||
report_interval=report_interval,
|
report_interval=report_interval,
|
||||||
periodic_enable=periodic_enable,
|
periodic_enable=periodic_enable,
|
||||||
periodic_fuzzy_delay=periodic_fuzzy_delay,
|
periodic_fuzzy_delay=periodic_fuzzy_delay,
|
||||||
periodic_interval_max=periodic_interval_max)
|
periodic_interval_max=periodic_interval_max,
|
||||||
|
db_allowed=db_allowed)
|
||||||
|
|
||||||
return service_obj
|
return service_obj
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user