Remove nova-volume scheduling support
Continuation of I0b540e54dbabd26901a7530035a38583bb521fda * delete scheduler.simple * modify scheduler.multi instead of delete to continue supporting I753e87fc8979fd0b62529974f00cf11fa55b3d63 * update scheduler.multi docstring * scheduler.rpcapi bumped to 2.3 * change default scheduler to scheduler.filter_scheduler DocImpact part of bp delete-nova-volume Change-Id: Ie9d9b46742b2d92cd1e9ffe982ef658907a1d411
This commit is contained in:
parent
a93f67c2ac
commit
58373748ac
@ -48,16 +48,6 @@ The :mod:`nova.scheduler.chance` Driver
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
The :mod:`nova.scheduler.simple` Driver
|
||||
---------------------------------------
|
||||
|
||||
.. automodule:: nova.scheduler.simple
|
||||
:noindex:
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
|
||||
Tests
|
||||
-----
|
||||
|
||||
|
@ -92,11 +92,3 @@ class ChanceScheduler(driver.Scheduler):
|
||||
filter_properties)
|
||||
self.compute_rpcapi.prep_resize(context, image, instance,
|
||||
instance_type, host, reservations)
|
||||
|
||||
def schedule_create_volume(self, context, volume_id, snapshot_id,
|
||||
image_id):
|
||||
"""Picks a host that is up at random."""
|
||||
host = self._schedule(context, FLAGS.volume_topic, None, {})
|
||||
driver.cast_to_host(context, FLAGS.volume_topic, host, 'create_volume',
|
||||
volume_id=volume_id, snapshot_id=snapshot_id,
|
||||
image_id=image_id)
|
||||
|
@ -181,11 +181,6 @@ class Scheduler(object):
|
||||
msg = _("Driver must implement schedule_run_instance")
|
||||
raise NotImplementedError(msg)
|
||||
|
||||
def schedule_create_volume(self, context, volume_id, snapshot_id,
|
||||
image_id):
|
||||
msg = _("Driver must implement schedule_create_volune")
|
||||
raise NotImplementedError(msg)
|
||||
|
||||
def schedule_live_migration(self, context, instance, dest,
|
||||
block_migration, disk_over_commit):
|
||||
"""Live migration scheduling method.
|
||||
|
@ -42,13 +42,6 @@ class FilterScheduler(driver.Scheduler):
|
||||
self.cost_function_cache = {}
|
||||
self.options = scheduler_options.SchedulerOptions()
|
||||
|
||||
def schedule_create_volume(self, context, volume_id, snapshot_id, image_id,
|
||||
reservations):
|
||||
# NOTE: We're only focused on compute instances right now,
|
||||
# so this method will always raise NoValidHost().
|
||||
msg = _("No host selection for %s defined.") % FLAGS.volume_topic
|
||||
raise exception.NoValidHost(reason=msg)
|
||||
|
||||
def schedule_run_instance(self, context, request_spec,
|
||||
admin_password, injected_files,
|
||||
requested_networks, is_first_time,
|
||||
|
@ -42,7 +42,7 @@ from nova import quota
|
||||
LOG = logging.getLogger(__name__)
|
||||
|
||||
scheduler_driver_opt = cfg.StrOpt('scheduler_driver',
|
||||
default='nova.scheduler.multi.MultiScheduler',
|
||||
default='nova.scheduler.filter_scheduler.FilterScheduler',
|
||||
help='Default driver to use for the scheduler')
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
@ -54,7 +54,7 @@ QUOTAS = quota.QUOTAS
|
||||
class SchedulerManager(manager.Manager):
|
||||
"""Chooses a host to run instances on."""
|
||||
|
||||
RPC_API_VERSION = '2.2'
|
||||
RPC_API_VERSION = '2.3'
|
||||
|
||||
def __init__(self, scheduler_driver=None, *args, **kwargs):
|
||||
if not scheduler_driver:
|
||||
@ -72,14 +72,8 @@ class SchedulerManager(manager.Manager):
|
||||
|
||||
def create_volume(self, context, volume_id, snapshot_id,
|
||||
reservations=None, image_id=None):
|
||||
try:
|
||||
self.driver.schedule_create_volume(
|
||||
context, volume_id, snapshot_id, image_id)
|
||||
except Exception as ex:
|
||||
with excutils.save_and_reraise_exception():
|
||||
LOG.warning(_("Failed to schedule create_volume: %(ex)s") %
|
||||
locals())
|
||||
db.volume_update(context, volume_id, {'status': 'error'})
|
||||
#function removed in RPC API 2.3
|
||||
pass
|
||||
|
||||
def live_migration(self, context, instance, dest,
|
||||
block_migration, disk_over_commit):
|
||||
|
@ -19,6 +19,12 @@
|
||||
|
||||
"""
|
||||
Scheduler that allows routing some calls to one driver and others to another.
|
||||
|
||||
This scheduler was originally used to deal with both compute and volume. But
|
||||
is now used for openstack extensions that want to use the nova-scheduler to
|
||||
schedule requests to compute nodes but provide their own manager and topic.
|
||||
|
||||
https://bugs.launchpad.net/nova/+bug/1009681
|
||||
"""
|
||||
|
||||
from nova import flags
|
||||
@ -32,9 +38,6 @@ multi_scheduler_opts = [
|
||||
default='nova.scheduler.'
|
||||
'filter_scheduler.FilterScheduler',
|
||||
help='Driver to use for scheduling compute calls'),
|
||||
cfg.StrOpt('volume_scheduler_driver',
|
||||
default='nova.scheduler.chance.ChanceScheduler',
|
||||
help='Driver to use for scheduling volume calls'),
|
||||
cfg.StrOpt('default_scheduler_driver',
|
||||
default='nova.scheduler.chance.ChanceScheduler',
|
||||
help='Default driver to use for scheduling calls'),
|
||||
@ -56,13 +59,10 @@ class MultiScheduler(driver.Scheduler):
|
||||
super(MultiScheduler, self).__init__()
|
||||
compute_driver = importutils.import_object(
|
||||
FLAGS.compute_scheduler_driver)
|
||||
volume_driver = importutils.import_object(
|
||||
FLAGS.volume_scheduler_driver)
|
||||
default_driver = importutils.import_object(
|
||||
FLAGS.default_scheduler_driver)
|
||||
|
||||
self.drivers = {'compute': compute_driver,
|
||||
'volume': volume_driver,
|
||||
'default': default_driver}
|
||||
|
||||
def schedule_run_instance(self, *args, **kwargs):
|
||||
@ -71,9 +71,6 @@ class MultiScheduler(driver.Scheduler):
|
||||
def schedule_prep_resize(self, *args, **kwargs):
|
||||
return self.drivers['compute'].schedule_prep_resize(*args, **kwargs)
|
||||
|
||||
def schedule_create_volume(self, *args, **kwargs):
|
||||
return self.drivers['volume'].schedule_create_volume(*args, **kwargs)
|
||||
|
||||
def update_service_capabilities(self, service_name, host, capabilities):
|
||||
# Multi scheduler is only a holder of sub-schedulers, so
|
||||
# pass the capabilities to the schedulers that matter
|
||||
|
@ -46,6 +46,7 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
||||
2.0 - Remove 1.x backwards compat
|
||||
2.1 - Add image_id to create_volume()
|
||||
2.2 - Remove reservations argument to create_volume()
|
||||
2.3 - Remove create_volume()
|
||||
'''
|
||||
|
||||
#
|
||||
@ -95,13 +96,6 @@ class SchedulerAPI(nova.openstack.common.rpc.proxy.RpcProxy):
|
||||
disk_over_commit=disk_over_commit, instance=instance_p,
|
||||
dest=dest))
|
||||
|
||||
def create_volume(self, ctxt, volume_id, snapshot_id, image_id):
|
||||
self.cast(ctxt,
|
||||
self.make_msg('create_volume',
|
||||
volume_id=volume_id, snapshot_id=snapshot_id,
|
||||
image_id=image_id),
|
||||
version='2.2')
|
||||
|
||||
def update_service_capabilities(self, ctxt, service_name, host,
|
||||
capabilities):
|
||||
self.fanout_cast(ctxt, self.make_msg('update_service_capabilities',
|
||||
|
@ -1,97 +0,0 @@
|
||||
# vim: tabstop=4 shiftwidth=4 softtabstop=4
|
||||
|
||||
# Copyright (c) 2010 OpenStack, LLC.
|
||||
# Copyright 2010 United States Government as represented by the
|
||||
# Administrator of the National Aeronautics and Space Administration.
|
||||
# All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
||||
# not use this file except in compliance with the License. You may obtain
|
||||
# a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
"""
|
||||
Simple Scheduler - for Volumes
|
||||
|
||||
Note: Deprecated in Folsom. Will be removed along with nova-volumes
|
||||
"""
|
||||
|
||||
from nova.common import deprecated
|
||||
from nova import db
|
||||
from nova import exception
|
||||
from nova import flags
|
||||
from nova.openstack.common import cfg
|
||||
from nova.scheduler import chance
|
||||
from nova.scheduler import driver
|
||||
from nova import utils
|
||||
|
||||
|
||||
simple_scheduler_opts = [
|
||||
cfg.IntOpt("max_gigabytes",
|
||||
default=10000,
|
||||
help="maximum number of volume gigabytes to allow per host"),
|
||||
]
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
FLAGS.register_opts(simple_scheduler_opts)
|
||||
|
||||
|
||||
class SimpleScheduler(chance.ChanceScheduler):
|
||||
"""Implements Naive Scheduler that tries to find least loaded host."""
|
||||
|
||||
def schedule_run_instance(self, context, request_spec, admin_password,
|
||||
injected_files, requested_networks,
|
||||
is_first_time, filter_properties):
|
||||
deprecated.warn(_('SimpleScheduler now only covers volume scheduling '
|
||||
'and is deprecated in Folsom. Non-volume functionality in '
|
||||
'SimpleScheduler has been replaced by FilterScheduler'))
|
||||
super(SimpleScheduler, self).schedule_run_instance(context,
|
||||
request_spec, admin_password, injected_files,
|
||||
requested_networks, is_first_time, filter_properties)
|
||||
|
||||
def schedule_create_volume(self, context, volume_id, snapshot_id,
|
||||
image_id):
|
||||
"""Picks a host that is up and has the fewest volumes."""
|
||||
deprecated.warn(_('nova-volume functionality is deprecated in Folsom '
|
||||
'and will be removed in Grizzly. Volumes are now handled '
|
||||
'by Cinder'))
|
||||
elevated = context.elevated()
|
||||
|
||||
volume_ref = db.volume_get(context, volume_id)
|
||||
availability_zone = volume_ref.get('availability_zone')
|
||||
|
||||
zone, host = None, None
|
||||
if availability_zone:
|
||||
zone, _x, host = availability_zone.partition(':')
|
||||
if host and context.is_admin:
|
||||
service = db.service_get_by_args(elevated, host, 'nova-volume')
|
||||
if not utils.service_is_up(service):
|
||||
raise exception.WillNotSchedule(host=host)
|
||||
driver.cast_to_volume_host(context, host, 'create_volume',
|
||||
volume_id=volume_id, snapshot_id=snapshot_id,
|
||||
image_id=image_id)
|
||||
return None
|
||||
|
||||
results = db.service_get_all_volume_sorted(elevated)
|
||||
if zone:
|
||||
results = [(service, gigs) for (service, gigs) in results
|
||||
if service['availability_zone'] == zone]
|
||||
for result in results:
|
||||
(service, volume_gigabytes) = result
|
||||
if volume_gigabytes + volume_ref['size'] > FLAGS.max_gigabytes:
|
||||
msg = _("Not enough allocatable volume gigabytes remaining")
|
||||
raise exception.NoValidHost(reason=msg)
|
||||
if utils.service_is_up(service) and not service['disabled']:
|
||||
driver.cast_to_volume_host(context, service['host'],
|
||||
'create_volume', volume_id=volume_id,
|
||||
snapshot_id=snapshot_id, image_id=image_id)
|
||||
return None
|
||||
msg = _("Is the appropriate service running?")
|
||||
raise exception.NoValidHost(reason=msg)
|
@ -20,7 +20,7 @@ from nova import flags
|
||||
|
||||
FLAGS = flags.FLAGS
|
||||
|
||||
flags.DECLARE('compute_scheduler_driver', 'nova.scheduler.multi')
|
||||
flags.DECLARE('scheduler_driver', 'nova.scheduler.manager')
|
||||
flags.DECLARE('fake_network', 'nova.network.manager')
|
||||
flags.DECLARE('iscsi_num_targets', 'nova.volume.driver')
|
||||
flags.DECLARE('network_size', 'nova.network.manager')
|
||||
|
@ -69,7 +69,7 @@ class _IntegratedTestBase(test.TestCase):
|
||||
|
||||
self.stub_module('crypto', fake_crypto)
|
||||
nova.tests.image.fake.stub_out_image_service(self.stubs)
|
||||
self.flags(compute_scheduler_driver='nova.scheduler.'
|
||||
self.flags(scheduler_driver='nova.scheduler.'
|
||||
'chance.ChanceScheduler')
|
||||
|
||||
# set up services
|
||||
|
@ -36,14 +36,6 @@ class FakeComputeScheduler(driver.Scheduler):
|
||||
pass
|
||||
|
||||
|
||||
class FakeVolumeScheduler(driver.Scheduler):
|
||||
is_fake_volume = True
|
||||
|
||||
def __init__(self):
|
||||
super(FakeVolumeScheduler, self).__init__()
|
||||
self.is_update_caps_called = False
|
||||
|
||||
|
||||
class FakeDefaultScheduler(driver.Scheduler):
|
||||
is_fake_default = True
|
||||
|
||||
@ -61,18 +53,15 @@ class MultiDriverTestCase(test_scheduler.SchedulerTestCase):
|
||||
super(MultiDriverTestCase, self).setUp()
|
||||
base_name = 'nova.tests.scheduler.test_multi_scheduler.%s'
|
||||
compute_cls_name = base_name % 'FakeComputeScheduler'
|
||||
volume_cls_name = base_name % 'FakeVolumeScheduler'
|
||||
default_cls_name = base_name % 'FakeDefaultScheduler'
|
||||
self.flags(compute_scheduler_driver=compute_cls_name,
|
||||
volume_scheduler_driver=volume_cls_name,
|
||||
default_scheduler_driver=default_cls_name)
|
||||
self._manager = multi.MultiScheduler()
|
||||
|
||||
def test_drivers_inited(self):
|
||||
mgr = self._manager
|
||||
self.assertEqual(len(mgr.drivers), 3)
|
||||
self.assertEqual(len(mgr.drivers), 2)
|
||||
self.assertTrue(mgr.drivers['compute'].is_fake_compute)
|
||||
self.assertTrue(mgr.drivers['volume'].is_fake_volume)
|
||||
self.assertTrue(mgr.drivers['default'].is_fake_default)
|
||||
|
||||
def test_update_service_capabilities(self):
|
||||
@ -84,10 +73,8 @@ class MultiDriverTestCase(test_scheduler.SchedulerTestCase):
|
||||
'update_service_capabilities',
|
||||
fake_update_service_capabilities)
|
||||
self.assertFalse(mgr.drivers['compute'].is_update_caps_called)
|
||||
self.assertFalse(mgr.drivers['volume'].is_update_caps_called)
|
||||
mgr.update_service_capabilities('foo_svc', 'foo_host', 'foo_caps')
|
||||
self.assertTrue(mgr.drivers['compute'].is_update_caps_called)
|
||||
self.assertTrue(mgr.drivers['volume'].is_update_caps_called)
|
||||
|
||||
|
||||
class SimpleSchedulerTestCase(MultiDriverTestCase):
|
||||
@ -99,10 +86,8 @@ class SimpleSchedulerTestCase(MultiDriverTestCase):
|
||||
super(SimpleSchedulerTestCase, self).setUp()
|
||||
base_name = 'nova.tests.scheduler.test_multi_scheduler.%s'
|
||||
compute_cls_name = base_name % 'FakeComputeScheduler'
|
||||
volume_cls_name = 'nova.scheduler.simple.SimpleScheduler'
|
||||
default_cls_name = base_name % 'FakeDefaultScheduler'
|
||||
self.flags(compute_scheduler_driver=compute_cls_name,
|
||||
volume_scheduler_driver=volume_cls_name,
|
||||
default_scheduler_driver=default_cls_name)
|
||||
self._manager = multi.MultiScheduler()
|
||||
|
||||
@ -117,11 +102,9 @@ class SimpleSchedulerTestCase(MultiDriverTestCase):
|
||||
self.assertFalse(mgr.drivers['compute'].is_update_caps_called)
|
||||
mgr.update_service_capabilities('foo_svc', 'foo_host', 'foo_caps')
|
||||
self.assertTrue(mgr.drivers['compute'].is_update_caps_called)
|
||||
self.assertTrue(mgr.drivers['volume'].is_update_caps_called)
|
||||
|
||||
def test_drivers_inited(self):
|
||||
mgr = self._manager
|
||||
self.assertEqual(len(mgr.drivers), 3)
|
||||
self.assertEqual(len(mgr.drivers), 2)
|
||||
self.assertTrue(mgr.drivers['compute'].is_fake_compute)
|
||||
self.assertTrue(mgr.drivers['volume'] is not None)
|
||||
self.assertTrue(mgr.drivers['default'].is_fake_default)
|
||||
|
@ -83,9 +83,3 @@ class SchedulerRpcAPITestCase(test.TestCase):
|
||||
self._test_scheduler_api('update_service_capabilities',
|
||||
rpc_method='fanout_cast', service_name='fake_name',
|
||||
host='fake_host', capabilities='fake_capabilities')
|
||||
|
||||
def test_create_volume(self):
|
||||
self._test_scheduler_api('create_volume',
|
||||
rpc_method='cast', volume_id="fake_volume",
|
||||
snapshot_id="fake_snapshots", image_id="fake_image",
|
||||
version='2.2')
|
||||
|
Loading…
Reference in New Issue
Block a user