Removing cinder-all binary

It was deprecated in Newton to be removed in Ocata, in favor of using
the individual binaries.

Change-Id: I0981722b94279871e1941881ac5b3e565ffa6c44
This commit is contained in:
Mike Perez 2016-10-02 14:14:11 -07:00
parent 3499070caa
commit dafc68aa56
5 changed files with 6 additions and 300 deletions

View File

@ -1,117 +0,0 @@
#!/usr/bin/env python
# Copyright 2011 OpenStack Foundation
# 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.
"""Starter script for All cinder services.
This script attempts to start all the cinder services in one process. Each
service is started in its own greenthread. Please note that exceptions and
sys.exit() on the starting of a service are logged and the script will
continue attempting to launch the rest of the services.
"""
import eventlet
eventlet.monkey_patch()
import sys
from oslo_config import cfg
from oslo_log import log as logging
from oslo_log import versionutils
from oslo_reports import guru_meditation_report as gmr
from oslo_reports import opts as gmr_opts
from cinder import i18n
i18n.enable_lazy()
# Need to register global_opts
from cinder.cmd import volume as volume_cmd
from cinder.common import config # noqa
from cinder.db import api as session
from cinder.i18n import _LE, _, _LW
from cinder import objects
from cinder import rpc
from cinder import service
from cinder import utils
from cinder import version
CONF = cfg.CONF
# TODO(e0ne): get a rid of code duplication in cinder.cmd module in Mitaka
def main():
objects.register_all()
gmr_opts.set_defaults(CONF)
CONF(sys.argv[1:], project='cinder',
version=version.version_string())
config.set_middleware_defaults()
logging.setup(CONF, "cinder")
LOG = logging.getLogger('cinder.all')
versionutils.report_deprecated_feature(LOG, _(
'cinder-all is deprecated in Newton and will be removed in Ocata.'))
utils.monkey_patch()
gmr.TextGuruMeditation.setup_autorun(version, conf=CONF)
rpc.init(CONF)
launcher = service.process_launcher()
# cinder-api
try:
server = service.WSGIService('osapi_volume')
launcher.launch_service(server, workers=server.workers or 1)
except (Exception, SystemExit):
LOG.exception(_LE('Failed to load osapi_volume'))
for binary in ['cinder-scheduler', 'cinder-backup']:
try:
launcher.launch_service(service.Service.create(binary=binary))
except (Exception, SystemExit):
LOG.exception(_LE('Failed to load %s'), binary)
# cinder-volume
try:
if CONF.enabled_backends:
for backend in filter(None, CONF.enabled_backends):
CONF.register_opt(volume_cmd.host_opt, group=backend)
backend_host = getattr(CONF, backend).backend_host
host = "%s@%s" % (backend_host or CONF.host, backend)
server = service.Service.create(host=host,
service_name=backend,
binary='cinder-volume',
coordination=True)
# Dispose of the whole DB connection pool here before
# starting another process. Otherwise we run into cases
# where child processes share DB connections which results
# in errors.
session.dispose_engine()
launcher.launch_service(server)
else:
LOG.warning(_LW('Configuration for cinder-volume does not specify '
'"enabled_backends", using DEFAULT as backend. '
'Support for DEFAULT section to configure drivers '
'will be removed in the next release.'))
server = service.Service.create(binary='cinder-volume',
coordination=True)
launcher.launch_service(server)
except (Exception, SystemExit):
LOG.exception(_LE('Failed to load cinder-volume'))
launcher.wait()

View File

@ -29,7 +29,6 @@ from cinder.backup.drivers import posix as cinder_backup_drivers_posix
from cinder.backup.drivers import swift as cinder_backup_drivers_swift
from cinder.backup.drivers import tsm as cinder_backup_drivers_tsm
from cinder.backup import manager as cinder_backup_manager
from cinder.cmd import all as cinder_cmd_all
from cinder.cmd import volume as cinder_cmd_volume
from cinder.common import config as cinder_common_config
import cinder.compute
@ -225,7 +224,7 @@ def list_opts():
cinder_volume_drivers_netapp_options.netapp_replication_opts,
cinder_volume_drivers_ibm_storwize_svc_storwizesvciscsi.
storwize_svc_iscsi_opts,
cinder_backup_drivers_glusterfs.glusterfsbackup_service_opts,
cinder_compute_nova.nova_opts,
cinder_volume_drivers_coprhd_scaleio.scaleio_opts,
cinder_backup_drivers_tsm.tsm_opts,
cinder_volume_drivers_fujitsu_eternusdxcommon.
@ -335,7 +334,7 @@ def list_opts():
cinder_volume_drivers_hgst.hgst_opts,
cinder_message_api.messages_opts,
cinder_image_imageutils.image_helper_opts,
cinder_compute_nova.nova_opts,
cinder_backup_drivers_glusterfs.glusterfsbackup_service_opts,
cinder_volume_drivers_ibm_flashsystemfc.flashsystem_fc_opts,
cinder_volume_drivers_prophetstor_options.DPL_OPTS,
cinder_volume_drivers_hpe_hpexpopts.FC_VOLUME_OPTS,
@ -380,6 +379,5 @@ def list_opts():
('BACKEND',
itertools.chain(
[cinder_cmd_volume.host_opt],
[cinder_cmd_all.volume_cmd.host_opt],
)),
]

View File

@ -26,7 +26,6 @@ except ImportError:
import rtslib as rtslib_fb
from cinder.cmd import all as cinder_all
from cinder.cmd import api as cinder_api
from cinder.cmd import backup as cinder_backup
from cinder.cmd import manage as cinder_manage
@ -112,183 +111,6 @@ class TestCinderBackupCmd(test.TestCase):
service_wait.assert_called_once_with()
class TestCinderAllCmd(test.TestCase):
def setUp(self):
super(TestCinderAllCmd, self).setUp()
sys.argv = ['cinder-all']
def tearDown(self):
super(TestCinderAllCmd, self).tearDown()
@mock.patch('oslo_log.versionutils.report_deprecated_feature')
@mock.patch('cinder.rpc.init')
@mock.patch('cinder.service.Service.create')
@mock.patch('cinder.service.WSGIService')
@mock.patch('cinder.service.process_launcher')
@mock.patch('cinder.utils.monkey_patch')
@mock.patch('oslo_log.log.getLogger')
@mock.patch('oslo_log.log.setup')
def test_main(self, log_setup, get_logger, monkey_patch, process_launcher,
wsgi_service, service_create, rpc_init, mock_log_utils):
CONF.set_override('enabled_backends', None)
launcher = process_launcher.return_value
server = wsgi_service.return_value
server.workers = mock.sentinel.worker_count
service = service_create.return_value
cinder_all.main()
self.assertTrue(mock_log_utils.called)
self.assertEqual('cinder', CONF.project)
self.assertEqual(CONF.version, version.version_string())
log_setup.assert_called_once_with(CONF, "cinder")
get_logger.assert_called_once_with('cinder.all')
monkey_patch.assert_called_once_with()
rpc_init.assert_called_once_with(CONF)
process_launcher.assert_called_once_with()
wsgi_service.assert_called_once_with('osapi_volume')
launcher.launch_service.assert_any_call(server, workers=server.workers)
service_create.assert_has_calls([
mock.call(binary='cinder-scheduler'),
mock.call(binary='cinder-backup'),
mock.call(binary='cinder-volume', coordination=True)],
any_order=True)
self.assertEqual(3, service_create.call_count)
launcher.launch_service.assert_has_calls([mock.call(service)] * 3)
self.assertEqual(4, launcher.launch_service.call_count)
launcher.wait.assert_called_once_with()
@mock.patch('cinder.rpc.init')
@mock.patch('cinder.service.Service.create')
@mock.patch('cinder.service.WSGIService')
@mock.patch('cinder.service.process_launcher')
@mock.patch('cinder.utils.monkey_patch')
@mock.patch('oslo_log.log.getLogger')
@mock.patch('oslo_log.log.setup')
def test_main_with_backend(self, log_setup, get_logger, monkey_patch,
process_launcher, wsgi_service, service_create,
rpc_init):
CONF.set_override('enabled_backends', ['', 'backend1', ''])
CONF.set_override('host', 'host')
launcher = process_launcher.return_value
server = wsgi_service.return_value
server.workers = mock.sentinel.worker_count
service = service_create.return_value
cinder_all.main()
self.assertEqual('cinder', CONF.project)
self.assertEqual(CONF.version, version.version_string())
log_setup.assert_called_once_with(CONF, "cinder")
get_logger.assert_called_once_with('cinder.all')
monkey_patch.assert_called_once_with()
rpc_init.assert_called_once_with(CONF)
process_launcher.assert_called_once_with()
wsgi_service.assert_called_once_with('osapi_volume')
launcher.launch_service.assert_any_call(server, workers=server.workers)
service_create.assert_has_calls([mock.call(binary='cinder-scheduler'),
mock.call(binary='cinder-backup'),
mock.call(binary='cinder-volume',
host='host@backend1',
service_name='backend1',
coordination=True)],
any_order=True)
self.assertEqual(3, service_create.call_count)
launcher.launch_service.assert_has_calls([mock.call(service)] * 3)
self.assertEqual(4, launcher.launch_service.call_count)
launcher.wait.assert_called_once_with()
@mock.patch('cinder.rpc.init')
@mock.patch('cinder.service.Service.create')
@mock.patch('cinder.service.WSGIService')
@mock.patch('cinder.service.process_launcher')
@mock.patch('cinder.utils.monkey_patch')
@mock.patch('oslo_log.log.getLogger')
@mock.patch('oslo_log.log.setup')
def test_main_load_osapi_volume_exception(self, log_setup, get_logger,
monkey_patch, process_launcher,
wsgi_service, service_create,
rpc_init):
launcher = process_launcher.return_value
server = wsgi_service.return_value
server.workers = mock.sentinel.worker_count
mock_log = get_logger.return_value
for ex in (Exception(), SystemExit()):
launcher.launch_service.side_effect = ex
cinder_all.main()
self.assertEqual('cinder', CONF.project)
self.assertEqual(CONF.version, version.version_string())
log_setup.assert_called_once_with(CONF, "cinder")
get_logger.assert_called_once_with('cinder.all')
monkey_patch.assert_called_once_with()
process_launcher.assert_called_once_with()
wsgi_service.assert_called_once_with('osapi_volume')
rpc_init.assert_called_with(CONF)
launcher.launch_service.assert_any_call(server,
workers=server.workers)
self.assertTrue(mock_log.exception.called)
# Reset for the next exception
log_setup.reset_mock()
get_logger.reset_mock()
monkey_patch.reset_mock()
process_launcher.reset_mock()
wsgi_service.reset_mock()
mock_log.reset_mock()
@mock.patch('cinder.rpc.init')
@mock.patch('cinder.service.Service.create')
@mock.patch('cinder.service.WSGIService')
@mock.patch('cinder.service.process_launcher')
@mock.patch('cinder.utils.monkey_patch')
@mock.patch('oslo_log.log.getLogger')
@mock.patch('oslo_log.log.setup')
def test_main_load_binary_exception(self, log_setup, get_logger,
monkey_patch, process_launcher,
wsgi_service, service_create,
rpc_init):
CONF.set_override('enabled_backends', None)
launcher = process_launcher.return_value
server = wsgi_service.return_value
server.workers = mock.sentinel.worker_count
service = service_create.return_value
mock_log = get_logger.return_value
def launch_service(*args, **kwargs):
if service in args:
raise Exception()
launcher.launch_service.side_effect = launch_service
cinder_all.main()
self.assertEqual('cinder', CONF.project)
self.assertEqual(CONF.version, version.version_string())
log_setup.assert_called_once_with(CONF, "cinder")
get_logger.assert_called_once_with('cinder.all')
monkey_patch.assert_called_once_with()
process_launcher.assert_called_once_with()
wsgi_service.assert_called_once_with('osapi_volume')
launcher.launch_service.assert_any_call(server,
workers=server.workers)
services = (('cinder-volume', {'coordination': True}),
('cinder-backup', {}),
('cinder-scheduler', {}))
for binary, params in services:
service_create.assert_any_call(binary=binary, **params)
launcher.launch_service.assert_called_with(service)
rpc_init.assert_called_once_with(CONF)
self.assertTrue(mock_log.exception.called)
class TestCinderSchedulerCmd(test.TestCase):
def setUp(self):

View File

@ -0,0 +1,4 @@
---
upgrade:
- Removing cinder-all binary. Instead use the individual binaries like
cinder-api, cinder-backup, cinder-volume, cinder-scheduler.

View File

@ -46,7 +46,6 @@ oslo.config.opts =
oslo.config.opts.defaults =
cinder = cinder.common.config:set_middleware_defaults
console_scripts =
cinder-all = cinder.cmd.all:main
cinder-api = cinder.cmd.api:main
cinder-backup = cinder.cmd.backup:main
cinder-manage = cinder.cmd.manage:main