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
This commit is contained in:
Arata Notsu
2012-10-25 20:24:23 +09:00
parent fe8685cc26
commit 9ac10f55e4
5 changed files with 19 additions and 4 deletions

View File

@@ -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."""

View File

@@ -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.

View File

@@ -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,

View File

@@ -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)

View File

@@ -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,