GMR: Allow disabling signal handler

Some services such as nova introduced GMR for API wsgi application
so that GMR can be generated via a file handler. However the current
setup method tries to register signal handler and causes warnings.

For example we are seeing the following error when starting nova-api
by apache + mod_wsgi.

mod_wsgi (pid=80323): Callback registration for signal 12 ignored.
  File "/var/www/cgi-bin/nova/nova-api", line 52, in <module>
    application = init_application()
  File "/usr/lib/python3.9/site-packages/nova/api/openstack/compute/wsgi.py", line 20, in init_application
    return wsgi_app.init_application(NAME)
  File "/usr/lib/python3.9/site-packages/nova/api/openstack/wsgi_app.py", line 128, in init_application
    init_global_data(conf_files, name)
  File "/usr/lib/python3.9/site-packages/nova/utils.py", line 1122, in wrapper
    return func(*args, **kwargs)
  File "/usr/lib/python3.9/site-packages/nova/api/openstack/wsgi_app.py", line 105, in init_global_data
    gmr.TextGuruMeditation.setup_autorun(
  File "/usr/lib/python3.9/site-packages/oslo_reports/guru_meditation_report.py", line 152, in setup_autorun
    cls._setup_signal(signal.SIGUSR2,
  File "/usr/lib/python3.9/site-packages/oslo_reports/guru_meditation_report.py", line 185, in _setup_signal
    signal.signal(signum,

This introduces the new argument so that we can disable signal handler
completely to avoid such warnings.

Change-Id: I95170542fecb493260a22d9148f3a2777207cb0e
This commit is contained in:
Takashi Kajinami 2023-08-03 21:33:41 +09:00
parent 61ce374f19
commit db11260c11

View File

@ -120,7 +120,8 @@ class GuruMeditation(object):
@classmethod
def setup_autorun(cls, version, service_name=None,
log_dir=None, signum=None, conf=None):
log_dir=None, signum=None, conf=None,
setup_signal=True):
"""Set Up Auto-Run
This method sets up the Guru Meditation Report to automatically
@ -133,13 +134,15 @@ class GuruMeditation(object):
:param logdir: path to a log directory where to create a file
:param signum: the signal to associate with running the report
:param conf: Configuration object, managed by the caller.
:param setup_signal: Set up a signal handler
"""
if log_dir is None and conf is not None:
log_dir = conf.oslo_reports.log_dir
if signum:
cls._setup_signal(signum, version, service_name, log_dir)
if setup_signal:
cls._setup_signal(signum, version, service_name, log_dir)
return
if conf and conf.oslo_reports.file_event_handler:
@ -148,7 +151,7 @@ class GuruMeditation(object):
conf.oslo_reports.file_event_handler_interval,
version, service_name, log_dir)
else:
if hasattr(signal, 'SIGUSR2'):
if setup_signal and hasattr(signal, 'SIGUSR2'):
cls._setup_signal(signal.SIGUSR2,
version, service_name, log_dir)