From db11260c114eaf9a309c5ead9db4226677769053 Mon Sep 17 00:00:00 2001 From: Takashi Kajinami Date: Thu, 3 Aug 2023 21:33:41 +0900 Subject: [PATCH] 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 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 --- oslo_reports/guru_meditation_report.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/oslo_reports/guru_meditation_report.py b/oslo_reports/guru_meditation_report.py index a0fb7d6..0277f2e 100644 --- a/oslo_reports/guru_meditation_report.py +++ b/oslo_reports/guru_meditation_report.py @@ -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)