]> review.fuel-infra Code Review - openstack-build/cinder-build.git/commitdiff
Use OSprofiler options consolidated in lib itself
authorDina Belova <dbelova@mirantis.com>
Tue, 9 Feb 2016 23:58:14 +0000 (15:58 -0800)
committerDina Belova <dbelova@mirantis.com>
Wed, 2 Mar 2016 14:24:53 +0000 (17:24 +0300)
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

cinder/db/sqlalchemy/api.py
cinder/opts.py
cinder/service.py
cinder/volume/manager.py

index 6ba28dd98f5f4999106ef8f316bc3123f2d45306..062c03be9c7b94319bbd2bed3c3ba42554da5607 100644 (file)
@@ -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(),
index aebbfd072b50dfb13b43a68d2cf63505c4f9ee4a..d943dda22ba0039942834961f093835d673cee68 100644 (file)
@@ -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.
index 95b72804e72a95e317e211e396556d5d8832ae34..e9ad71015fc72688c4a9b066eccbced4b63f09af 100644 (file)
@@ -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,
index 207be480e52d5852ff1ed44c5e065ca09f4dba20..e4fbd8ce90aa68ca216b71714e6e4902ba14e01d 100644 (file)
@@ -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(