Support reload configuration on SIGHUP
This adds signal handler to reload mutable configuration options on SIGHUP. It has to be done manually, because ironic-inspector doesn't use oslo.service. Change-Id: I38955fe9dbfd339df2a10dcbb55e996bf515034a Story: #1585595 Task: #12543
This commit is contained in:
parent
1ae010bb70
commit
76898b7382
@ -422,3 +422,20 @@ class TestCreateSSLContext(test_base.BaseTest):
|
||||
self.assertEqual(mock_context, con)
|
||||
mock_context.load_cert_chain.assert_called_once_with(cert_path,
|
||||
key_path)
|
||||
|
||||
|
||||
class TestWSGIServiceOnSigHup(BaseWSGITest):
|
||||
def setUp(self):
|
||||
super(TestWSGIServiceOnSigHup, self).setUp()
|
||||
self.mock_spawn = self.useFixture(fixtures.MockPatchObject(
|
||||
wsgi_service.eventlet, 'spawn')).mock
|
||||
self.mock_mutate_conf = self.useFixture(fixtures.MockPatchObject(
|
||||
wsgi_service.CONF, 'mutate_config_files')).mock
|
||||
|
||||
def test_on_sighup(self):
|
||||
self.service._handle_sighup()
|
||||
self.mock_spawn.assert_called_once_with(self.service._handle_sighup_bg)
|
||||
|
||||
def test_on_sighup_bg(self):
|
||||
self.service._handle_sighup_bg()
|
||||
self.mock_mutate_conf.assert_called_once_with()
|
||||
|
@ -10,6 +10,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import signal
|
||||
import ssl
|
||||
import sys
|
||||
import traceback as traceback_mod
|
||||
@ -41,6 +42,7 @@ class WSGIService(object):
|
||||
self.app = app.app
|
||||
self._periodics_worker = None
|
||||
self._shutting_down = semaphore.Semaphore()
|
||||
signal.signal(signal.SIGHUP, self._handle_sighup)
|
||||
|
||||
def _init_middleware(self):
|
||||
"""Initialize WSGI middleware.
|
||||
@ -189,6 +191,13 @@ class WSGIService(object):
|
||||
else:
|
||||
self.shutdown()
|
||||
|
||||
def _handle_sighup_bg(self, *args):
|
||||
"""Reload config on SIGHUP."""
|
||||
CONF.mutate_config_files()
|
||||
|
||||
def _handle_sighup(self, *args):
|
||||
eventlet.spawn(self._handle_sighup_bg, *args)
|
||||
|
||||
|
||||
def periodic_clean_up(): # pragma: no cover
|
||||
try:
|
||||
|
11
releasenotes/notes/sighup-support-e6eaec034d963108.yaml
Normal file
11
releasenotes/notes/sighup-support-e6eaec034d963108.yaml
Normal file
@ -0,0 +1,11 @@
|
||||
---
|
||||
features:
|
||||
- |
|
||||
Issuing a SIGHUP to the ironic-inspector service will cause the service to
|
||||
reload and use any changed values for *mutable* configuration options.
|
||||
|
||||
Mutable configuration options are indicated as such in the `sample
|
||||
configuration file <https://docs.openstack.org/ironic-inspector/latest/configuration/sample-config.html>`_
|
||||
by ``Note: This option can be changed without restarting``.
|
||||
|
||||
A warning is logged for any changes to immutable configuration options.
|
Loading…
Reference in New Issue
Block a user