summaryrefslogtreecommitdiffstats
path: root/nova/compute
diff options
context:
space:
mode:
authorRussell Bryant <rbryant@redhat.com>2013-01-11 11:56:09 -0500
committerRussell Bryant <rbryant@redhat.com>2013-01-11 18:06:54 -0500
commit42f3d0bdbda3c54c0d3490e0f407e7dbb8f574ca (patch)
treec5a05b4050bc47ec94fed6965ecef44dd399525a /nova/compute
parent6ea308295a158b4700f4081913f66596fc769b36 (diff)
Make pinging conductor a part of conductor API.
This patch moves the loop that pings the conductor over rpc until it responds to be a part of the conductor API. This will allow it to be used elsewhere in the code as needed. Part of bp no-db-compute. Change-Id: Ie027adef4a3af3059b4ab586e927c93ae1a86fe9
Diffstat (limited to 'nova/compute')
-rw-r--r--nova/compute/manager.py30
1 files changed, 4 insertions, 26 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index f138a3708..98ed1286e 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -358,32 +358,6 @@ class ComputeManager(manager.SchedulerDependentManager):
'trying to set it to ERROR'),
instance_uuid=instance_uuid)
- def _get_instances_at_startup(self, context):
- '''Get instances for this host during service init.'''
- attempt = 0
- timeout = 10
- while True:
- # NOTE(danms): Try ten times with a short timeout, and then punt
- # to the configured RPC timeout after that
- if attempt == 10:
- timeout = None
- attempt += 1
-
- # NOTE(russellb): This is running during service startup. If we
- # allow an exception to be raised, the service will shut down.
- # This may fail the first time around if nova-conductor wasn't
- # running when nova-compute started.
- try:
- self.conductor_api.ping(context, '1.21 GigaWatts',
- timeout=timeout)
- break
- except rpc_common.Timeout as e:
- LOG.exception(_('Timed out waiting for nova-conductor. '
- 'Is it running? Or did nova-compute start '
- 'before nova-conductor?'))
-
- return self.conductor_api.instance_get_all_by_host(context, self.host)
-
def _get_instances_on_driver(self, context):
"""Return a list of instance records that match the instances found
on the hypervisor.
@@ -504,6 +478,10 @@ class ComputeManager(manager.SchedulerDependentManager):
LOG.warning(_('Hypervisor driver does not support '
'firewall rules'), instance=instance)
+ def _get_instances_at_startup(self, context):
+ self.conductor_api.wait_until_ready(context)
+ return self.conductor_api.instance_get_all_by_host(context, self.host)
+
def init_host(self):
"""Initialization for a standalone compute service."""
self.driver.init_host(host=self.host)