From: Dina Belova Date: Tue, 9 Feb 2016 23:58:14 +0000 (-0800) Subject: Use OSprofiler options consolidated in lib itself X-Git-Url: https://review.fuel-infra.org/gitweb?a=commitdiff_plain;h=16660696f91236369ffa7a943f5ff7279a445199;p=openstack-build%2Fcinder-build.git Use OSprofiler options consolidated in lib itself Starting with 1.0.0 osprofiler release options needed for its workability are consolidated inside osprofiler itself. Let's use them. UpgradeImpact DocImpact Change-Id: Ie20e827f26c9be6867c233afdea9e05e2869d6e1 --- diff --git a/cinder/db/sqlalchemy/api.py b/cinder/db/sqlalchemy/api.py index 6ba28dd98..062c03be9 100644 --- a/cinder/db/sqlalchemy/api.py +++ b/cinder/db/sqlalchemy/api.py @@ -84,7 +84,7 @@ def _create_facade_lazily(): # which requires db.sqlalchemy.api, which requires service which # requires objects.base CONF.import_group("profiler", "cinder.service") - if CONF.profiler.profiler_enabled: + if CONF.profiler.enabled: if CONF.profiler.trace_sqlalchemy: osprofiler_sqlalchemy.add_tracing(sqlalchemy, _FACADE.get_engine(), diff --git a/cinder/opts.py b/cinder/opts.py index aebbfd072..d943dda22 100644 --- a/cinder/opts.py +++ b/cinder/opts.py @@ -333,10 +333,6 @@ def list_opts(): cinder_volume_drivers_vzstorage.vzstorage_opts, cinder_volume_drivers_nfs.nfs_opts, )), - ('PROFILER', - itertools.chain( - cinder_service.profiler_opts, - )), ('BRCD_FABRIC_EXAMPLE', itertools.chain( cinder_zonemanager_drivers_brocade_brcdfabricopts. diff --git a/cinder/service.py b/cinder/service.py index 95b72804e..e9ad71015 100644 --- a/cinder/service.py +++ b/cinder/service.py @@ -34,6 +34,7 @@ from oslo_utils import importutils osprofiler_notifier = importutils.try_import('osprofiler.notifier') profiler = importutils.try_import('osprofiler.profiler') osprofiler_web = importutils.try_import('osprofiler.web') +profiler_opts = importutils.try_import('osprofiler.opts') from cinder import context from cinder import exception @@ -69,28 +70,22 @@ service_opts = [ help='Number of workers for OpenStack Volume API service. ' 'The default is equal to the number of CPUs available.'), ] -profiler_opts = [ - cfg.BoolOpt("profiler_enabled", default=False, - help=_('If False fully disable profiling feature.')), - cfg.BoolOpt("trace_sqlalchemy", default=False, - help=_("If False doesn't trace SQL requests.")), - cfg.StrOpt("hmac_keys", default="SECRET_KEY", - help=_("Secret key to use to sign tracing messages.")) -] CONF = cfg.CONF CONF.register_opts(service_opts) -CONF.register_opts(profiler_opts, group="profiler") +if profiler_opts: + profiler_opts.set_defaults(CONF) def setup_profiler(binary, host): if (osprofiler_notifier is None or profiler is None or - osprofiler_web is None): + osprofiler_web is None or + profiler_opts is None): LOG.debug('osprofiler is not present') return - if CONF.profiler.profiler_enabled: + if CONF.profiler.enabled: _notifier = osprofiler_notifier.create( "Messaging", messaging, context.get_admin_context().to_dict(), rpc.TRANSPORT, "cinder", binary, host) @@ -105,7 +100,7 @@ def setup_profiler(binary, host): "trigger profiler, only admin user can retrieve trace " "information.\n" "To disable OSprofiler set in cinder.conf:\n" - "[profiler]\nprofiler_enabled=false")) + "[profiler]\nenabled=false")) else: osprofiler_web.disable() @@ -131,7 +126,7 @@ class Service(service.Service): self.topic = topic self.manager_class_name = manager manager_class = importutils.import_class(self.manager_class_name) - if CONF.profiler.profiler_enabled: + if CONF.profiler.enabled: manager_class = profiler.trace_cls("rpc")(manager_class) self.manager = manager_class(host=self.host, diff --git a/cinder/volume/manager.py b/cinder/volume/manager.py index 207be480e..e4fbd8ce9 100644 --- a/cinder/volume/manager.py +++ b/cinder/volume/manager.py @@ -264,7 +264,7 @@ class VolumeManager(manager.SchedulerDependentManager): is_vol_db_empty=vol_db_empty, active_backend_id=curr_active_backend_id) - if CONF.profiler.profiler_enabled and profiler is not None: + if CONF.profiler.enabled and profiler is not None: self.driver = profiler.trace_cls("driver")(self.driver) try: self.extra_capabilities = jsonutils.loads(