summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorArata Notsu <notsu@virtualtech.jp>2012-10-25 20:24:23 +0900
committerArata Notsu <notsu@virtualtech.jp>2012-10-28 09:05:59 +0900
commit9ac10f55e4b40ac496c20f56501e5aeffa196692 (patch)
tree3532217bcf588bc15f9a23a1ed1d6efca615ddd9 /nova
parentfe8685cc2646d2f947a890f2013220995c78fa10 (diff)
Let scheduler know services' capabilities at startup
Fixes bug 1071254. Changes: * Add new rpc-api(fanout) of compute "publish_service_capabilities" This rpc-api urges services to send its capabilites to the scheduler. * Scheduler calls publish_service_capabilities right after the start By them, the scheduler get to know the capabilities earlier. Now we can expect that the scheduler always holds the capabilities. So it is reasonable to change HostManager to ignore hosts whose capabilities are "None" since it becomes a rare case; this will make scheduling more reliable. This will achieved by Another patch. Change-Id: If6582765011fd5e1b794bfdc068e17630ba381cb
Diffstat (limited to 'nova')
-rw-r--r--nova/compute/manager.py4
-rw-r--r--nova/compute/rpcapi.py4
-rw-r--r--nova/manager.py8
-rw-r--r--nova/scheduler/manager.py4
-rw-r--r--nova/service.py3
5 files changed, 19 insertions, 4 deletions
diff --git a/nova/compute/manager.py b/nova/compute/manager.py
index dcdf3f148..24a040d7e 100644
--- a/nova/compute/manager.py
+++ b/nova/compute/manager.py
@@ -217,7 +217,7 @@ def _get_image_meta(context, image_ref):
class ComputeManager(manager.SchedulerDependentManager):
"""Manages the running instances from creation to destruction."""
- RPC_API_VERSION = '2.8'
+ RPC_API_VERSION = '2.9'
def __init__(self, compute_driver=None, *args, **kwargs):
"""Load configuration options and connect to the hypervisor."""
@@ -345,7 +345,7 @@ class ComputeManager(manager.SchedulerDependentManager):
self.driver.filter_defer_apply_off()
self._report_driver_status(context)
- self._publish_service_capabilities(context)
+ self.publish_service_capabilities(context)
def _get_power_state(self, context, instance):
"""Retrieve the power state for the given instance."""
diff --git a/nova/compute/rpcapi.py b/nova/compute/rpcapi.py
index cb1ddede8..38d9b3426 100644
--- a/nova/compute/rpcapi.py
+++ b/nova/compute/rpcapi.py
@@ -136,6 +136,7 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
2.6 - Remove migration_id, add migration to resize_instance
2.7 - Remove migration_id, add migration to confirm_resize
2.8 - Remove migration_id, add migration to finish_resize
+ 2.9 - Add publish_service_capabilities()
'''
#
@@ -529,6 +530,9 @@ class ComputeAPI(nova.openstack.common.rpc.proxy.RpcProxy):
instance=instance_p),
topic=_compute_topic(self.topic, ctxt, None, instance))
+ def publish_service_capabilities(self, ctxt):
+ self.fanout_cast(ctxt, self.make_msg('publish_service_capabilities'))
+
class SecurityGroupAPI(nova.openstack.common.rpc.proxy.RpcProxy):
'''Client side of the security group rpc API.
diff --git a/nova/manager.py b/nova/manager.py
index 275d98b61..2a7570c3b 100644
--- a/nova/manager.py
+++ b/nova/manager.py
@@ -225,8 +225,12 @@ class SchedulerDependentManager(Manager):
self.last_capabilities = capabilities
@periodic_task
- def _publish_service_capabilities(self, context):
- """Pass data back to the scheduler at a periodic interval."""
+ def publish_service_capabilities(self, context):
+ """Pass data back to the scheduler.
+
+ Called at a periodic interval. And also called via rpc soon after
+ the start of the scheduler.
+ """
if self.last_capabilities:
LOG.debug(_('Notifying Schedulers of capabilities ...'))
self.scheduler_rpcapi.update_service_capabilities(context,
diff --git a/nova/scheduler/manager.py b/nova/scheduler/manager.py
index 824dc9eb0..4c3f8025a 100644
--- a/nova/scheduler/manager.py
+++ b/nova/scheduler/manager.py
@@ -23,6 +23,7 @@ Scheduler Service
import sys
+from nova.compute import rpcapi as compute_rpcapi
from nova.compute import utils as compute_utils
from nova.compute import vm_states
from nova import db
@@ -258,3 +259,6 @@ class SchedulerManager(manager.Manager):
@manager.periodic_task
def _expire_reservations(self, context):
QUOTAS.expire(context)
+
+ def request_service_capabilities(self, context):
+ compute_rpcapi.ComputeAPI().publish_service_capabilities(context)
diff --git a/nova/service.py b/nova/service.py
index caff1672a..ca128557f 100644
--- a/nova/service.py
+++ b/nova/service.py
@@ -426,6 +426,9 @@ class Service(object):
# Consume from all consumers in a thread
self.conn.consume_in_thread()
+ if 'nova-scheduler' == self.binary:
+ self.manager.request_service_capabilities(ctxt)
+
if self.report_interval:
pulse = utils.LoopingCall(self.report_state)
pulse.start(interval=self.report_interval,