From b189f2a67d3a05985926bc42be44ac9a2284273d Mon Sep 17 00:00:00 2001 From: Russell Bryant Date: Fri, 11 Jan 2013 14:11:08 -0500 Subject: [PATCH] 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 --- bin/nova-compute | 3 ++- nova/service.py | 13 ++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/bin/nova-compute b/bin/nova-compute index d93ddb5bd..8826015d4 100755 --- a/bin/nova-compute +++ b/bin/nova-compute @@ -55,6 +55,7 @@ if __name__ == '__main__': logging.setup('nova') utils.monkey_patch() server = service.Service.create(binary='nova-compute', - topic=CONF.compute_topic) + topic=CONF.compute_topic, + db_allowed=False) service.serve(server) service.wait() diff --git a/nova/service.py b/nova/service.py index 86f022f61..05049d464 100644 --- a/nova/service.py +++ b/nova/service.py @@ -30,6 +30,7 @@ import time import eventlet import greenlet +from nova import conductor from nova import context from nova import db 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 log as logging from nova.openstack.common import rpc +from nova.openstack.common.rpc import common as rpc_common from nova import servicegroup from nova import utils from nova import version @@ -392,7 +394,7 @@ class Service(object): def __init__(self, host, binary, topic, manager, report_interval=None, periodic_enable=None, periodic_fuzzy_delay=None, - periodic_interval_max=None, + periodic_interval_max=None, db_allowed=True, *args, **kwargs): self.host = host self.binary = binary @@ -407,6 +409,9 @@ class Service(object): self.saved_args, self.saved_kwargs = args, kwargs self.timers = [] 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() def start(self): @@ -481,7 +486,8 @@ class Service(object): @classmethod def create(cls, host=None, binary=None, topic=None, manager=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. :param host: defaults to CONF.host @@ -514,7 +520,8 @@ class Service(object): report_interval=report_interval, periodic_enable=periodic_enable, 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