Make BackupManager not a SchedulerDependentManager
BackupManager isn't really reporting anything to scheduler and is inheriting from SchedulerDependentManager only because it uses _add_to_threadpool method. This commit extracts this method into new ThreadPoolManager class and makes BackupManager to inherit it. Change-Id: I79e4c5e05571b6b52fed8885fe280a3d9d8726ea
This commit is contained in:
@@ -78,14 +78,14 @@ CONF.import_opt('num_volume_device_scan_tries', 'cinder.volume.driver')
|
||||
QUOTAS = quota.QUOTAS
|
||||
|
||||
|
||||
class BackupManager(manager.SchedulerDependentManager):
|
||||
class BackupManager(manager.ThreadPoolManager):
|
||||
"""Manages backup of block storage devices."""
|
||||
|
||||
RPC_API_VERSION = backup_rpcapi.BackupAPI.RPC_API_VERSION
|
||||
|
||||
target = messaging.Target(version=RPC_API_VERSION)
|
||||
|
||||
def __init__(self, service_name=None, *args, **kwargs):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self.service = importutils.import_module(self.driver_name)
|
||||
self.az = CONF.storage_availability_zone
|
||||
self.volume_managers = {}
|
||||
@@ -99,8 +99,7 @@ class BackupManager(manager.SchedulerDependentManager):
|
||||
self._setup_volume_drivers()
|
||||
self.backup_rpcapi = backup_rpcapi.BackupAPI()
|
||||
self.volume_rpcapi = volume_rpcapi.VolumeAPI()
|
||||
super(BackupManager, self).__init__(service_name='backup',
|
||||
*args, **kwargs)
|
||||
super(BackupManager, self).__init__(*args, **kwargs)
|
||||
|
||||
def _get_volume_backend(self, host=None, allow_null_host=False):
|
||||
if host is None:
|
||||
|
||||
+11
-6
@@ -85,7 +85,7 @@ class Manager(base.Base, PeriodicTasks):
|
||||
|
||||
target = messaging.Target(version=RPC_API_VERSION)
|
||||
|
||||
def __init__(self, host=None, db_driver=None, cluster=None):
|
||||
def __init__(self, host=None, db_driver=None, cluster=None, **kwargs):
|
||||
if not host:
|
||||
host = CONF.host
|
||||
self.host = host
|
||||
@@ -145,7 +145,16 @@ class Manager(base.Base, PeriodicTasks):
|
||||
rpc.LAST_RPC_VERSIONS = {}
|
||||
|
||||
|
||||
class SchedulerDependentManager(Manager):
|
||||
class ThreadPoolManager(Manager):
|
||||
def __init__(self, *args, **kwargs):
|
||||
self._tp = greenpool.GreenPool()
|
||||
super(ThreadPoolManager, self).__init__(*args, **kwargs)
|
||||
|
||||
def _add_to_threadpool(self, func, *args, **kwargs):
|
||||
self._tp.spawn_n(func, *args, **kwargs)
|
||||
|
||||
|
||||
class SchedulerDependentManager(ThreadPoolManager):
|
||||
"""Periodically send capability updates to the Scheduler services.
|
||||
|
||||
Services that need to update the Scheduler of their capabilities
|
||||
@@ -160,7 +169,6 @@ class SchedulerDependentManager(Manager):
|
||||
self.last_capabilities = None
|
||||
self.service_name = service_name
|
||||
self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
|
||||
self._tp = greenpool.GreenPool()
|
||||
super(SchedulerDependentManager, self).__init__(host, db_driver,
|
||||
cluster=cluster)
|
||||
|
||||
@@ -194,9 +202,6 @@ class SchedulerDependentManager(Manager):
|
||||
"during a live upgrade. Error: %(e)s")
|
||||
LOG.warning(msg, {'host': self.host, 'e': e})
|
||||
|
||||
def _add_to_threadpool(self, func, *args, **kwargs):
|
||||
self._tp.spawn_n(func, *args, **kwargs)
|
||||
|
||||
def reset(self):
|
||||
super(SchedulerDependentManager, self).reset()
|
||||
self.scheduler_rpcapi = scheduler_rpcapi.SchedulerAPI()
|
||||
|
||||
@@ -291,7 +291,7 @@ class BackupTestCase(BaseBackupTest):
|
||||
self.assertTrue(self.volume_mocks['detach_volume'].called)
|
||||
|
||||
@mock.patch('cinder.objects.backup.BackupList.get_all_by_host')
|
||||
@mock.patch('cinder.manager.SchedulerDependentManager._add_to_threadpool')
|
||||
@mock.patch('cinder.manager.ThreadPoolManager._add_to_threadpool')
|
||||
def test_init_host_with_service_inithost_offload(self,
|
||||
mock_add_threadpool,
|
||||
mock_get_all_by_host):
|
||||
|
||||
Reference in New Issue
Block a user