Put ensure_share into thread pool to speed up the startup of share service
when we need to start or restart manila share service, will call init_host(). and call ensure_driver_resources() in init_host(), will call self.driver.ensure_shares or self.driver.ensure_share to update all share instances in that host. Currently, only NetApp and LVM implement self.driver.ensure_shares, Other manufacturers are using self.driver.ensure_share. in large-scale environment, there are lot of share instances in one host. this will lead to take much time to ensure_share. so we can put this operation into the thread pool to speed up the startup of the service. Closes-Bug: #1909847 Change-Id: I295d0de0958ebfedd89441f1a2c1b447b74693a0
This commit is contained in:
parent
475eeafd8d
commit
a8e25b858d
@ -51,6 +51,8 @@ This module provides Manager, a base class for managers.
|
||||
|
||||
"""
|
||||
|
||||
|
||||
from eventlet import greenpool
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from oslo_service import periodic_task
|
||||
@ -139,8 +141,12 @@ 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)
|
||||
|
||||
def _add_to_threadpool(self, func, *args, **kwargs):
|
||||
self._tp.spawn_n(func, *args, **kwargs)
|
||||
|
||||
def update_service_capabilities(self, capabilities):
|
||||
"""Remember these capabilities to send on next periodic update."""
|
||||
self.last_capabilities = capabilities
|
||||
|
@ -131,6 +131,10 @@ share_manager_opts = [
|
||||
'configured, this option must be set to False. '
|
||||
'If set to False - gathering share usage size will be'
|
||||
' disabled.'),
|
||||
cfg.BoolOpt('share_service_inithost_offload',
|
||||
default=False,
|
||||
help='Offload pending share ensure during '
|
||||
'share service startup'),
|
||||
]
|
||||
|
||||
CONF = cfg.CONF
|
||||
@ -447,7 +451,12 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||
LOG.exception("Caught exception trying ensure "
|
||||
"share instances.")
|
||||
else:
|
||||
self._ensure_share(ctxt, update_share_instances)
|
||||
for share_instance in update_share_instances:
|
||||
if CONF.share_service_inithost_offload:
|
||||
self._add_to_threadpool(self._ensure_share,
|
||||
ctxt, share_instance)
|
||||
else:
|
||||
self._ensure_share(ctxt, share_instance)
|
||||
|
||||
if new_backend_info:
|
||||
self.db.backend_info_update(
|
||||
@ -517,20 +526,19 @@ class ShareManager(manager.SchedulerDependentManager):
|
||||
"access rules for snapshot instance %s.",
|
||||
snap_instance['id'])
|
||||
|
||||
def _ensure_share(self, ctxt, share_instances):
|
||||
for share_instance in share_instances:
|
||||
try:
|
||||
export_locations = self.driver.ensure_share(
|
||||
ctxt, share_instance,
|
||||
share_server=share_instance['share_server'])
|
||||
except Exception:
|
||||
LOG.exception("Caught exception trying ensure "
|
||||
"share '%(s_id)s'.",
|
||||
{'s_id': share_instance['id']})
|
||||
continue
|
||||
if export_locations:
|
||||
self.db.share_export_locations_update(
|
||||
ctxt, share_instance['id'], export_locations)
|
||||
def _ensure_share(self, ctxt, share_instance):
|
||||
export_locations = None
|
||||
try:
|
||||
export_locations = self.driver.ensure_share(
|
||||
ctxt, share_instance,
|
||||
share_server=share_instance['share_server'])
|
||||
except Exception:
|
||||
LOG.exception("Caught exception trying ensure "
|
||||
"share '%(s_id)s'.",
|
||||
{'s_id': share_instance['id']})
|
||||
if export_locations:
|
||||
self.db.share_export_locations_update(
|
||||
ctxt, share_instance['id'], export_locations)
|
||||
|
||||
def _check_share_server_backend_limits(
|
||||
self, context, available_share_servers, share_instance=None):
|
||||
|
@ -0,0 +1,16 @@
|
||||
---
|
||||
upgrade:
|
||||
- |
|
||||
This fix introduces a new configuration item, which named
|
||||
"share_service_inithost_offload", default value is False, if set it True,
|
||||
will put ensure_share operation into thread pool to speed up startup of
|
||||
manila share service.
|
||||
fixes:
|
||||
- |
|
||||
The manila share servie now can put ensure_share operation into thread
|
||||
pool during service startup process. See `Launchpad bug#1890833
|
||||
<https://launchpad.net/bugs/1909847>`_ for more details.
|
||||
- |
|
||||
The manila share service now honors the configuration option
|
||||
"share_service_inithost_offload", and it can be used to reduce the time
|
||||
required for the manila share aervice to start up.
|
Loading…
x
Reference in New Issue
Block a user