From 9f93694b9ae41811c43d66ce56d34422f9991f06 Mon Sep 17 00:00:00 2001 From: Dmitry Tantsur Date: Thu, 2 Apr 2020 11:05:11 +0200 Subject: [PATCH] Make oslo.reports an optional dependency It is only required for one specific feature, let people install it if they need it. This change is a part of the major effort to reduce the number of ironic dependencies. Change-Id: Ia45ce1d573c89f583d641be3d37d1c127e6345bc --- doc/source/admin/gmr.rst | 10 ++++++++++ ironic/cmd/api.py | 14 ++++++++++++-- ironic/cmd/conductor.py | 11 +++++++++-- .../oslo-reports-optional-59469955eaffdf1d.yaml | 6 ++++++ requirements.txt | 1 - setup.cfg | 4 ++++ 6 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 releasenotes/notes/oslo-reports-optional-59469955eaffdf1d.yaml diff --git a/doc/source/admin/gmr.rst b/doc/source/admin/gmr.rst index 7b638492d3..61da8f070d 100644 --- a/doc/source/admin/gmr.rst +++ b/doc/source/admin/gmr.rst @@ -12,6 +12,16 @@ and more. The eventlet backdoor facility provides an interactive shell interface for any eventlet based process, allowing an administrator to telnet to a pre-defined port and execute a variety of commands. +Configuration +------------- + +The GMR feature is optional and requires the oslo.reports_ package to be +installed. For example, using pip:: + + pip install 'oslo.reports>=1.18.0' + +.. _oslo.reports: https://opendev.org/openstack/oslo.reports + Generating a GMR ---------------- diff --git a/ironic/cmd/api.py b/ironic/cmd/api.py index 74333e72e0..1e8dbcdf61 100644 --- a/ironic/cmd/api.py +++ b/ironic/cmd/api.py @@ -20,7 +20,11 @@ import sys from oslo_config import cfg -from oslo_reports import guru_meditation_report as gmr +from oslo_log import log +try: + from oslo_reports import guru_meditation_report as gmr +except ImportError: + gmr = None from ironic.common import profiler from ironic.common import service as ironic_service @@ -29,12 +33,18 @@ from ironic import version CONF = cfg.CONF +LOG = log.getLogger(__name__) + def main(): # Parse config file and command line options, then start logging ironic_service.prepare_service(sys.argv) - gmr.TextGuruMeditation.setup_autorun(version) + if gmr is not None: + gmr.TextGuruMeditation.setup_autorun(version) + else: + LOG.debug('Guru meditation reporting is disabled ' + 'because oslo.reports is not installed') profiler.setup('ironic_api', CONF.host) diff --git a/ironic/cmd/conductor.py b/ironic/cmd/conductor.py index cce0818398..d8fbcfec9c 100644 --- a/ironic/cmd/conductor.py +++ b/ironic/cmd/conductor.py @@ -23,7 +23,10 @@ import sys from oslo_config import cfg from oslo_log import log -from oslo_reports import guru_meditation_report as gmr +try: + from oslo_reports import guru_meditation_report as gmr +except ImportError: + gmr = None from oslo_service import service from ironic.common import profiler @@ -83,7 +86,11 @@ def main(): # Parse config file and command line options, then start logging ironic_service.prepare_service(sys.argv) - gmr.TextGuruMeditation.setup_autorun(version) + if gmr is not None: + gmr.TextGuruMeditation.setup_autorun(version) + else: + LOG.debug('Guru meditation reporting is disabled ' + 'because oslo.reports is not installed') mgr = rpc_service.RPCService(CONF.host, 'ironic.conductor.manager', diff --git a/releasenotes/notes/oslo-reports-optional-59469955eaffdf1d.yaml b/releasenotes/notes/oslo-reports-optional-59469955eaffdf1d.yaml new file mode 100644 index 0000000000..25e9f3f814 --- /dev/null +++ b/releasenotes/notes/oslo-reports-optional-59469955eaffdf1d.yaml @@ -0,0 +1,6 @@ +--- +upgrade: + - | + The guru meditation reporting functionality is now optional and the + ``oslo.reports`` package is no longer a part of requirements. Install it + manually if you need this feature. diff --git a/requirements.txt b/requirements.txt index fff36d71ba..4f4a1a1a9e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -25,7 +25,6 @@ oslo.i18n>=3.15.3 # Apache-2.0 oslo.log>=3.36.0 # Apache-2.0 oslo.middleware>=3.31.0 # Apache-2.0 oslo.policy>=1.30.0 # Apache-2.0 -oslo.reports>=1.18.0 # Apache-2.0 oslo.serialization!=2.19.1,>=2.18.0 # Apache-2.0 oslo.service!=1.28.1,>=1.24.0 # Apache-2.0 oslo.upgradecheck>=0.1.0 # Apache-2.0 diff --git a/setup.cfg b/setup.cfg index aeaac7e7c4..5dd3dc4fe9 100644 --- a/setup.cfg +++ b/setup.cfg @@ -196,3 +196,7 @@ output_file = ironic/locale/ironic.pot [wheel] universal = 1 + +[extras] +guru_meditation_reports = + oslo.reports>=1.18.0 # Apache-2.0