Removed RPC topic config options

Cinder had config options to customize the RPC topics on which the
scheduler, volume and backup nodes listen. But this feature has been
dysfunctional for quite a long time. This commit removed this feature.
For more details: Refer the bug comments.

DocImpact
Change-Id: Ie76f070fe9a1222c209e8defd0d04fa7a7931b14
Closes-Bug: #1301888
This commit is contained in:
Vivek Dhayaal 2016-03-02 22:14:15 +05:30
parent 583217f447
commit f6c20ed00b
26 changed files with 75 additions and 79 deletions

View File

@ -22,6 +22,7 @@ import webob.exc
from cinder.api import extensions
from cinder.api.openstack import wsgi
from cinder.common import constants
from cinder import db
from cinder import exception
from cinder.i18n import _, _LI
@ -149,7 +150,7 @@ class HostController(wsgi.Controller):
# Not found exception will be handled at the wsgi level
host_ref = objects.Service.get_by_host_and_topic(
context, host, CONF.volume_topic)
context, host, constants.VOLUME_TOPIC)
# Getting total available/used resource
# TODO(jdg): Add summary info for Snapshots

View File

@ -12,7 +12,6 @@
# License for the specific language governing permissions and limitations
# under the License.
from oslo_config import cfg
from oslo_log import log as logging
from webob import exc
@ -25,7 +24,6 @@ from cinder.i18n import _
from cinder import volume as cinder_volume
LOG = logging.getLogger(__name__)
CONF = cfg.CONF
authorize_manage = extensions.extension_authorizer('snapshot',
'snapshot_manage')
authorize_list_manageable = extensions.extension_authorizer('snapshot',

View File

@ -29,6 +29,7 @@ from pytz import timezone
import random
from cinder.backup import rpcapi as backup_rpcapi
from cinder.common import constants
from cinder import context
from cinder.db import base
from cinder import exception
@ -144,7 +145,7 @@ class API(base.Base):
def _is_backup_service_enabled(self, availability_zone, host):
"""Check if there is a backup service available."""
topic = CONF.backup_topic
topic = constants.BACKUP_TOPIC
ctxt = context.get_admin_context()
services = objects.ServiceList.get_all_by_topic(
ctxt, topic, disabled=False)
@ -189,7 +190,7 @@ class API(base.Base):
:returns: list -- hosts for services that are enabled for backup.
"""
topic = CONF.backup_topic
topic = constants.BACKUP_TOPIC
ctxt = context.get_admin_context()
services = objects.ServiceList.get_all_by_topic(
ctxt, topic, disabled=False)

View File

@ -25,8 +25,6 @@ Volume backups can be created, restored, deleted and listed.
**Related Flags**
:backup_topic: What :mod:`rpc` topic to listen to (default:
`cinder-backup`).
:backup_manager: The module name of a class derived from
:class:`manager.Manager` (default:
:class:`cinder.backup.manager.Manager`).

View File

@ -18,13 +18,12 @@ Client side of the volume backup RPC API.
"""
from oslo_config import cfg
from oslo_log import log as logging
from cinder.common import constants
from cinder import rpc
CONF = cfg.CONF
LOG = logging.getLogger(__name__)
@ -49,7 +48,7 @@ class BackupAPI(rpc.RPCAPI):
"""
RPC_API_VERSION = '2.0'
TOPIC = CONF.backup_topic
TOPIC = constants.BACKUP_TOPIC
BINARY = 'cinder-backup'
def _compat_ver(self, current, legacy):

View File

@ -72,6 +72,7 @@ i18n.enable_lazy()
# Need to register global_opts
from cinder.common import config # noqa
from cinder.common import constants
from cinder import context
from cinder import db
from cinder.db import migration as db_migration
@ -266,7 +267,7 @@ class VolumeCommands(object):
if self._client is None:
if not rpc.initialized():
rpc.init(CONF)
target = messaging.Target(topic=CONF.volume_topic)
target = messaging.Target(topic=constants.VOLUME_TOPIC)
serializer = objects.base.CinderObjectSerializer()
self._client = rpc.get_client(target, serializer=serializer)

View File

@ -83,15 +83,6 @@ global_opts = [
help='http/https timeout value for glance operations. If no '
'value (None) is supplied here, the glanceclient default '
'value is used.'),
cfg.StrOpt('scheduler_topic',
default='cinder-scheduler',
help='The topic that scheduler nodes listen on'),
cfg.StrOpt('volume_topic',
default='cinder-volume',
help='The topic that volume nodes listen on'),
cfg.StrOpt('backup_topic',
default='cinder-backup',
help='The topic that volume backup nodes listen on'),
cfg.BoolOpt('enable_v1_api',
default=True,
deprecated_for_removal=True,

View File

@ -16,3 +16,11 @@
# The maximum value a signed INT type may have
DB_MAX_INT = 0x7FFFFFFF
# The cinder services binaries and topics' names
SCHEDULER_BINARY = "cinder-scheduler"
VOLUME_BINARY = "cinder-volume"
BACKUP_BINARY = "cinder-backup"
SCHEDULER_TOPIC = SCHEDULER_BINARY
VOLUME_TOPIC = VOLUME_BINARY
BACKUP_TOPIC = BACKUP_BINARY

View File

@ -25,6 +25,7 @@ from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import timeutils
from cinder.common import constants
from cinder import db
from cinder.db import base
from cinder import exception
@ -395,7 +396,7 @@ class API(base.Base):
# to select the target host for this group.
self.scheduler_rpcapi.create_consistencygroup(
context,
CONF.volume_topic,
constants.VOLUME_TOPIC,
group,
request_spec_list=request_spec_list,
filter_properties_list=filter_properties_list)

View File

@ -25,6 +25,7 @@ from oslo_log import log as logging
from oslo_utils import excutils
from oslo_utils import timeutils
from cinder.common import constants
from cinder.db import base
from cinder import exception
from cinder.i18n import _, _LE, _LW
@ -243,7 +244,7 @@ class API(base.Base):
# to select the target host for this group.
self.scheduler_rpcapi.create_group(
context,
CONF.volume_topic,
constants.VOLUME_TOPIC,
group,
group_spec=group_spec,
request_spec_list=request_spec_list,

View File

@ -24,6 +24,7 @@ from oslo_log import log as logging
from oslo_utils import importutils
from oslo_utils import timeutils
from cinder.common import constants
from cinder import context as cinder_context
from cinder import exception
from cinder import objects
@ -456,7 +457,7 @@ class HostManager(object):
def _update_host_state_map(self, context):
# Get resource usage across the available volume nodes:
topic = CONF.volume_topic
topic = constants.VOLUME_TOPIC
volume_services = objects.ServiceList.get_all_by_topic(context,
topic,
disabled=False)

View File

@ -16,15 +16,12 @@
Client side of the scheduler manager RPC API.
"""
from oslo_config import cfg
from oslo_serialization import jsonutils
from cinder.common import constants
from cinder import rpc
CONF = cfg.CONF
class SchedulerAPI(rpc.RPCAPI):
"""Client side of the scheduler rpc API.
@ -58,7 +55,7 @@ class SchedulerAPI(rpc.RPCAPI):
"""
RPC_API_VERSION = '2.3'
TOPIC = CONF.scheduler_topic
TOPIC = constants.SCHEDULER_TOPIC
BINARY = 'cinder-scheduler'
# FIXME(caosf): Remove unused argument 'topic' from functions

View File

@ -13,7 +13,6 @@
import fixtures
import mock
from oslo_concurrency import lockutils
from oslo_config import cfg
from oslo_config import fixture as config_fixture
import oslo_messaging as messaging
from oslo_serialization import jsonutils
@ -22,6 +21,7 @@ import webob
from webob import exc
from cinder.api.contrib import admin_actions
from cinder.common import constants
from cinder import context
from cinder import db
from cinder import exception
@ -38,8 +38,6 @@ from cinder.tests.unit import fake_snapshot
from cinder.volume import api as volume_api
from cinder.volume import rpcapi
CONF = cfg.CONF
def app():
# no auth, just let environ['cinder.context'] pass through
@ -475,11 +473,11 @@ class AdminActionsTest(BaseAdminTest):
# create volume's current host and the destination host
db.service_create(self.ctx,
{'host': 'test',
'topic': CONF.volume_topic,
'topic': constants.VOLUME_TOPIC,
'created_at': timeutils.utcnow()})
db.service_create(self.ctx,
{'host': 'test2',
'topic': CONF.volume_topic,
'topic': constants.VOLUME_TOPIC,
'created_at': timeutils.utcnow()})
# current status is available
volume = self._create_volume(self.ctx)

View File

@ -18,16 +18,14 @@ Tests For Allocated Capacity Weigher.
"""
import mock
from oslo_config import cfg
from cinder.common import constants
from cinder import context
from cinder.scheduler import weights
from cinder import test
from cinder.tests.unit.scheduler import fakes
from cinder.volume import utils
CONF = cfg.CONF
class AllocatedCapacityWeigherTestCase(test.TestCase):
def setUp(self):
@ -52,7 +50,7 @@ class AllocatedCapacityWeigherTestCase(test.TestCase):
_mock_service_get_all.assert_called_once_with(
ctxt,
None, # backend_match_level
topic=CONF.volume_topic, disabled=disabled)
topic=constants.VOLUME_TOPIC, disabled=disabled)
return host_states
def test_default_of_spreading_first(self):

View File

@ -17,16 +17,14 @@ Tests For Capacity Weigher.
"""
import mock
from oslo_config import cfg
from cinder.common import constants
from cinder import context
from cinder.scheduler import weights
from cinder import test
from cinder.tests.unit.scheduler import fakes
from cinder.volume import utils
CONF = cfg.CONF
class CapacityWeigherTestCase(test.TestCase):
def setUp(self):
@ -52,7 +50,7 @@ class CapacityWeigherTestCase(test.TestCase):
_mock_service_get_all.assert_called_once_with(
ctxt,
None, # backend_match_level
topic=CONF.volume_topic, disabled=disabled)
topic=constants.VOLUME_TOPIC, disabled=disabled)
return host_states
# If thin_provisioning_support = False, use the following formula:

View File

@ -19,9 +19,9 @@ Tests For HostManager
from datetime import datetime
import mock
from oslo_config import cfg
from oslo_utils import timeutils
from cinder.common import constants
from cinder import exception
from cinder import objects
from cinder.scheduler import filters
@ -30,9 +30,6 @@ from cinder import test
from cinder.tests.unit.objects import test_service
CONF = cfg.CONF
class FakeFilterClass1(filters.BaseHostFilter):
def host_passes(self, host_state, filter_properties):
pass
@ -211,7 +208,7 @@ class HostManagerTestCase(test.TestCase):
def test_get_all_host_states(self, _mock_service_is_up,
_mock_service_get_all):
context = 'fake_context'
topic = CONF.volume_topic
topic = constants.VOLUME_TOPIC
services = [
dict(id=1, host='host1', topic='volume', disabled=False,

View File

@ -17,8 +17,8 @@ Tests For Volume Number Weigher.
"""
import mock
from oslo_config import cfg
from cinder.common import constants
from cinder import context
from cinder.db.sqlalchemy import api
from cinder.scheduler import weights
@ -27,8 +27,6 @@ from cinder.tests.unit import fake_constants
from cinder.tests.unit.scheduler import fakes
from cinder.volume import utils
CONF = cfg.CONF
def fake_volume_data_get_for_host(context, host, count_only=False):
host = utils.extract_host(host)
@ -78,7 +76,7 @@ class VolumeNumberWeigherTestCase(test.TestCase):
_mock_service_get_all.assert_called_once_with(
ctxt,
None, # backend_match_level
topic=CONF.volume_topic,
topic=constants.VOLUME_TOPIC,
disabled=disabled)
return host_states

View File

@ -34,6 +34,7 @@ from cinder.cmd import rtstool as cinder_rtstool
from cinder.cmd import scheduler as cinder_scheduler
from cinder.cmd import volume as cinder_volume
from cinder.cmd import volume_usage_audit
from cinder.common import constants
from cinder import context
from cinder import exception
from cinder.objects import fields
@ -514,7 +515,6 @@ class TestCinderManageCmd(test.TestCase):
@mock.patch('oslo_messaging.Target')
def test_volume_commands_init(self, messaging_target, rpc_initialized,
rpc_init, get_client, object_serializer):
CONF.set_override('volume_topic', 'fake-topic')
mock_target = messaging_target.return_value
mock_rpc_client = get_client.return_value
@ -523,7 +523,7 @@ class TestCinderManageCmd(test.TestCase):
rpc_initialized.assert_called_once_with()
rpc_init.assert_called_once_with(CONF)
messaging_target.assert_called_once_with(topic='fake-topic')
messaging_target.assert_called_once_with(topic=constants.VOLUME_TOPIC)
get_client.assert_called_once_with(mock_target,
serializer=object_serializer())
self.assertEqual(mock_rpc_client, rpc_client)

View File

@ -22,6 +22,7 @@ import ddt
from oslo_config import cfg
from oslo_serialization import jsonutils
from cinder.common import constants
from cinder import context
from cinder import db
from cinder import objects
@ -179,7 +180,7 @@ class VolumeRpcAPITestCase(test.TestCase):
host = kwargs['cgsnapshot'].consistencygroup.host
target['server'] = utils.extract_host(host)
target['topic'] = '%s.%s' % (CONF.volume_topic, host)
target['topic'] = '%s.%s' % (constants.VOLUME_TOPIC, host)
self.fake_args = None
self.fake_kwargs = None
@ -259,7 +260,7 @@ class VolumeRpcAPITestCase(test.TestCase):
host = kwargs['group']['host']
target['server'] = utils.extract_host(host)
target['topic'] = '%s.%s' % (CONF.volume_topic, host)
target['topic'] = '%s.%s' % (constants.VOLUME_TOPIC, host)
self.fake_args = None
self.fake_kwargs = None

View File

@ -30,6 +30,7 @@ from oslo_utils import uuidutils
import six
from cinder.api import common
from cinder.common import constants
from cinder import context
from cinder import db
from cinder.db import base
@ -149,7 +150,7 @@ class API(base.Base):
if cache_age >= CONF.az_cache_duration:
refresh_cache = True
if refresh_cache or not enable_cache:
topic = CONF.volume_topic
topic = constants.VOLUME_TOPIC
ctxt = context.get_admin_context()
services = objects.ServiceList.get_all_by_topic(ctxt, topic)
az_data = [(s.availability_zone, s.disabled)
@ -177,9 +178,10 @@ class API(base.Base):
first_type=None, second_type=None):
safe = False
elevated = context.elevated()
services = objects.ServiceList.get_all_by_topic(elevated,
'cinder-volume',
disabled=True)
services = objects.ServiceList.get_all_by_topic(
elevated,
constants.VOLUME_TOPIC,
disabled=True)
if len(services.objects) == 1:
safe = True
else:
@ -1300,7 +1302,7 @@ class API(base.Base):
"""Migrate the volume to the specified host."""
# Make sure the host is in the list of available hosts
elevated = context.elevated()
topic = CONF.volume_topic
topic = constants.VOLUME_TOPIC
services = objects.ServiceList.get_all_by_topic(
elevated, topic, disabled=False)
found = False
@ -1358,7 +1360,7 @@ class API(base.Base):
'volume_type': volume_type,
'volume_id': volume.id}
self.scheduler_rpcapi.migrate_volume_to_host(context,
CONF.volume_topic,
constants.VOLUME_TOPIC,
volume.id,
host,
force_host_copy,
@ -1508,7 +1510,8 @@ class API(base.Base):
'quota_reservations': reservations,
'old_reservations': old_reservations}
self.scheduler_rpcapi.retype(context, CONF.volume_topic, volume.id,
self.scheduler_rpcapi.retype(context, constants.VOLUME_TOPIC,
volume.id,
request_spec=request_spec,
filter_properties={}, volume=volume)
LOG.info(_LI("Retype volume request issued successfully."),
@ -1524,7 +1527,7 @@ class API(base.Base):
with excutils.save_and_reraise_exception():
LOG.error(_LE('Unable to find service: %(service)s for '
'given host: %(host)s.'),
{'service': CONF.volume_topic, 'host': host})
{'service': constants.VOLUME_BINARY, 'host': host})
if service.disabled:
LOG.error(_LE('Unable to manage existing %s on a disabled '
@ -1622,7 +1625,7 @@ class API(base.Base):
svc_host = volume_utils.extract_host(host, 'backend')
service = objects.Service.get_by_args(
ctxt, svc_host, 'cinder-volume')
ctxt, svc_host, constants.VOLUME_BINARY)
expected = {'replication_status': [fields.ReplicationStatus.ENABLED,
fields.ReplicationStatus.FAILED_OVER]}
result = service.conditional_update(
@ -1644,7 +1647,7 @@ class API(base.Base):
svc_host = volume_utils.extract_host(host, 'backend')
service = objects.Service.get_by_args(
ctxt, svc_host, 'cinder-volume')
ctxt, svc_host, constants.VOLUME_BINARY)
expected = {'frozen': False}
result = service.conditional_update(
{'frozen': True}, expected)
@ -1665,7 +1668,7 @@ class API(base.Base):
svc_host = volume_utils.extract_host(host, 'backend')
service = objects.Service.get_by_args(
ctxt, svc_host, 'cinder-volume')
ctxt, svc_host, constants.VOLUME_BINARY)
expected = {'frozen': True}
result = service.conditional_update(
{'frozen': False}, expected)

View File

@ -19,6 +19,7 @@ import taskflow.engines
from taskflow.patterns import linear_flow
from taskflow.types import failure as ft
from cinder.common import constants
from cinder import exception
from cinder import flow_utils
from cinder.i18n import _, _LE, _LW
@ -762,7 +763,7 @@ class VolumeCastTask(flow_utils.CinderTask):
# to select the target host for this volume.
self.scheduler_rpcapi.create_volume(
context,
CONF.volume_topic,
constants.VOLUME_TOPIC,
volume_id,
snapshot_id=snapshot_id,
image_id=image_id,

View File

@ -11,12 +11,12 @@
# under the License.
from oslo_config import cfg
from oslo_log import log as logging
import taskflow.engines
from taskflow.patterns import linear_flow
from taskflow.types import failure as ft
from cinder.common import constants
from cinder import exception
from cinder import flow_utils
from cinder.i18n import _LE
@ -26,7 +26,6 @@ from cinder.volume.flows import common
LOG = logging.getLogger(__name__)
ACTION = 'volume:manage_existing'
CONF = cfg.CONF
class EntryCreateTask(flow_utils.CinderTask):
@ -109,7 +108,7 @@ class ManageCastTask(flow_utils.CinderTask):
# Call the scheduler to ensure that the host exists and that it can
# accept the volume
self.scheduler_rpcapi.manage_existing(context, CONF.volume_topic,
self.scheduler_rpcapi.manage_existing(context, constants.VOLUME_TOPIC,
volume.id,
request_spec=request_spec,
volume=volume)

View File

@ -20,6 +20,7 @@ import taskflow.engines
from taskflow.patterns import linear_flow
from taskflow.types import failure as ft
from cinder.common import constants
from cinder import context as cinder_context
from cinder import exception
from cinder import flow_utils
@ -143,7 +144,7 @@ class OnFailureRescheduleTask(flow_utils.CinderTask):
# Stringify to avoid circular ref problem in json serialization
retry_info['exc'] = traceback.format_exception(*cause.exc_info)
return create_volume(context, CONF.volume_topic, volume.id,
return create_volume(context, constants.VOLUME_TOPIC, volume.id,
request_spec=request_spec,
filter_properties=filter_properties,
volume=volume)

View File

@ -24,7 +24,6 @@ intact.
**Related Flags**
:volume_topic: What :mod:`rpc` topic to listen to (default: `cinder-volume`).
:volume_manager: The module name of a class derived from
:class:`manager.Manager` (default:
:class:`cinder.volume.manager.Manager`).
@ -54,6 +53,7 @@ profiler = importutils.try_import('osprofiler.profiler')
import six
from taskflow import exceptions as tfe
from cinder.common import constants
from cinder import compute
from cinder import context
from cinder import coordination
@ -212,7 +212,7 @@ class VolumeManager(manager.SchedulerDependentManager):
service = objects.Service.get_by_args(
context.get_admin_context(),
svc_host,
'cinder-volume')
constants.VOLUME_BINARY)
except exception.ServiceNotFound:
# NOTE(jdg): This is to solve problems with unit tests
LOG.info(_LI("Service not found for updating "
@ -522,7 +522,7 @@ class VolumeManager(manager.SchedulerDependentManager):
service = objects.Service.get_by_args(
context.get_admin_context(),
svc_host,
'cinder-volume')
constants.VOLUME_BINARY)
except exception.ServiceNotFound:
with excutils.save_and_reraise_exception():
LOG.error(_LE("Service not found for updating "
@ -3632,7 +3632,7 @@ class VolumeManager(manager.SchedulerDependentManager):
service = objects.Service.get_by_args(
context,
svc_host,
'cinder-volume')
constants.VOLUME_BINARY)
volumes = objects.VolumeList.get_all_by_host(context, self.host)
exception_encountered = False
@ -3741,7 +3741,7 @@ class VolumeManager(manager.SchedulerDependentManager):
service = objects.Service.get_by_args(
context,
svc_host,
'cinder-volume')
constants.VOLUME_BINARY)
service.disabled = True
service.disabled_reason = "frozen"
service.save()
@ -3774,7 +3774,7 @@ class VolumeManager(manager.SchedulerDependentManager):
service = objects.Service.get_by_args(
context,
svc_host,
'cinder-volume')
constants.VOLUME_BINARY)
service.disabled = False
service.disabled_reason = ""
service.save()

View File

@ -16,15 +16,14 @@
Client side of the volume RPC API.
"""
from oslo_config import cfg
from oslo_serialization import jsonutils
from cinder.common import constants
from cinder import quota
from cinder import rpc
from cinder.volume import utils
CONF = cfg.CONF
QUOTAS = quota.QUOTAS
@ -108,7 +107,7 @@ class VolumeAPI(rpc.RPCAPI):
"""
RPC_API_VERSION = '2.5'
TOPIC = CONF.volume_topic
TOPIC = constants.VOLUME_TOPIC
BINARY = 'cinder-volume'
def _compat_ver(self, current, *legacy):

View File

@ -0,0 +1,6 @@
---
fixes:
- The config options 'scheduler_topic', 'volume_topic'
and 'backup_topic' have been removed without a
deprecation period as these had never worked
correctly.