From 45b1c02d113051d147e54ef921ce8e94135542d8 Mon Sep 17 00:00:00 2001 From: Kashyap Chamarthy Date: Mon, 14 Sep 2015 16:17:37 +0200 Subject: [PATCH] guru_meditation_report: Use SIGUSR2 instead of SIGUSR1 Currently the setup_autorun() method expects the user-defined signal, SIGUSR1, to generate Guru Meditation Report upon killing a Nova Compute process, while supplying the said signal. However, testing in a DevStack environment, manually attempting to kill a Nova Compute process with SIGUSR1 [kill -s USR1 `pgrep nova-compute`] does not result in the process being terminated, and no error report is generated. It turns out[*] that SIGUSR1 is used by Apache 'mod_wsgi'. Using, the other user-defined signal, SIGUSR2 resolves this issue (i.e. 'nova-compute' process is terminated, and the Guru Meditation Report is generated successfully). So, use the signal USR2 instead of USR1. Also, update the corresponding tests. DocImpact: With this patch merged, to generate a successful Guru Meditation Report, supply the signal USR2 while killing a Nova Compute process [`kill -s USR2 `pgrep nova-compute`]. [*] https://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIRestrictSignal Change-Id: I9d3b6079ba2cca41fe4723723a6f80b2c3c0b9c0 --- oslo_reports/guru_meditation_report.py | 8 ++++---- oslo_reports/tests/test_guru_meditation_report.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/oslo_reports/guru_meditation_report.py b/oslo_reports/guru_meditation_report.py index 85b1869..f499ec1 100644 --- a/oslo_reports/guru_meditation_report.py +++ b/oslo_reports/guru_meditation_report.py @@ -51,7 +51,7 @@ Then, you can do .. code-block:: bash - $ kill -USR1 $SERVICE_PID + $ kill -USR2 $SERVICE_PID and get a Guru Meditation Report in the file or terminal where stderr is logged for that given service. @@ -128,9 +128,9 @@ class GuruMeditation(object): :param conf: Configuration object, managed by the caller. """ - if not signum and hasattr(signal, 'SIGUSR1'): - # SIGUSR1 is not supported on all platforms - signum = signal.SIGUSR1 + if not signum and hasattr(signal, 'SIGUSR2'): + # SIGUSR2 is not supported on all platforms + signum = signal.SIGUSR2 if signum: if log_dir is None and conf is not None: diff --git a/oslo_reports/tests/test_guru_meditation_report.py b/oslo_reports/tests/test_guru_meditation_report.py index ed836e7..964bac7 100644 --- a/oslo_reports/tests/test_guru_meditation_report.py +++ b/oslo_reports/tests/test_guru_meditation_report.py @@ -165,7 +165,7 @@ class TestGuruMeditationReport(base.BaseTestCase): self.old_stderr = sys.stderr sys.stderr = six.StringIO() - os.kill(os.getpid(), signal.SIGUSR1) + os.kill(os.getpid(), signal.SIGUSR2) self.assertIn('Guru Meditation', sys.stderr.getvalue()) @mock.patch('oslo_utils.timeutils.utcnow', @@ -175,7 +175,7 @@ class TestGuruMeditationReport(base.BaseTestCase): gmr.TextGuruMeditation.setup_autorun( FakeVersionObj(), "fake-service", log_dir) - os.kill(os.getpid(), signal.SIGUSR1) + os.kill(os.getpid(), signal.SIGUSR2) with open(os.path.join( log_dir, "fake-service_gurumeditation_20140101120000")) as df: self.assertIn('Guru Meditation', df.read())