use callback payloads for _SPAWN events

This patch switches callbacks over to the payload object style events
[1] for BEFORE_SPAWN and AFTER_SPAWN based notifications. As no event
data is passed for SPAWN notifications, an actual payload object is
not needed and thus this change uses publish() rather than notify()
and updates and callback receivers to accept the payload parameter.

NeutronLibImpact

[1] https://docs.openstack.org/neutron-lib/latest/contributor/callbacks.html#event-payloads

Change-Id: Ifad4781d82aa07f213f4e075b0c9455aa95e94bb
changes/92/527492/2
Boden R 5 years ago
parent 5641992591
commit 10644ad65b
  1. 4
      neutron/service.py
  2. 2
      neutron/tests/unit/test_service.py

@ -89,7 +89,7 @@ def serve_wsgi(cls):
LOG.exception('Unrecoverable error: please check log '
'for details.')
registry.notify(resources.PROCESS, events.BEFORE_SPAWN, service)
registry.publish(resources.PROCESS, events.BEFORE_SPAWN, service)
return service
@ -262,7 +262,7 @@ def _start_workers(workers):
def start_all_workers():
workers = _get_rpc_workers() + _get_plugins_workers()
launcher = _start_workers(workers)
registry.notify(resources.PROCESS, events.AFTER_SPAWN, None)
registry.publish(resources.PROCESS, events.AFTER_SPAWN, None)
return launcher

@ -69,4 +69,4 @@ class TestRunWsgiApp(base.BaseTestCase):
registry.subscribe(callback, resources.PROCESS, events.AFTER_SPAWN)
service.start_all_workers()
callback.assert_called_once_with(
resources.PROCESS, events.AFTER_SPAWN, mock.ANY)
resources.PROCESS, events.AFTER_SPAWN, mock.ANY, payload=None)

Loading…
Cancel
Save