]> review.fuel-infra Code Review - openstack-build/neutron-build.git/commit
Add support for PluginWorker and Process creation notification
authorTerry Wilson <twilson@redhat.com>
Tue, 16 Jun 2015 03:52:28 +0000 (22:52 -0500)
committerArmando Migliaccio <armamig@gmail.com>
Thu, 3 Sep 2015 06:40:50 +0000 (06:40 +0000)
commit9f6bd17703b7286be9e7d439d15f4dec2774e13a
treefbbf83f8c9a63da3ec550779c959a82b71576995
parent9ed4be7559b1b611b35b505a786c3511dccac58f
Add support for PluginWorker and Process creation notification

There are several cases where plugin initialization should be
handled after neutron-server forks API/RPC workers. For example,
starting a client connection to an SDN controller before forking
copies the fd of the socket to the child process, but then you have
multiple processes trying to read/write the same socket connection.

It is also useful for a plugin to be able to do something in only
one process, regardless of how many workers are forked. One example
would be handling syncing from an external system to the neutron
database.

This patch does 3 things:
1) Treats rpc_workers=0 as = 1. This simplifies the code for
   handling notification that forking has completed. In the
   existing code, calling the notification in the Worker object's
   start() method would happen twice in the case where both api
   and rpc workers were 0, despite there being only one process.
   An earlier patch already changed the default api_workers to be
   the number of processors.
2) Adds notification of forking via the callbacks mechanism.
   Plugins can subscribe to resources.PROCESS, event.AFTER_CREATE
   and do any post-fork initialization that needs to be done for
   every spawned process.
3) Adds core/service plugin calls to get_workers() which defaults
   to returning (). Plugins that need additional processes to spawn
   should just return an iterable of NeutronWorkers that will be
   spawned in their own process.

DocImpact

Closes-Bug: #1463129
Change-Id: Ib99954678c2b4f32f486b537979d446aafbea07b
14 files changed:
etc/neutron.conf
neutron/callbacks/resources.py
neutron/manager.py
neutron/neutron_plugin_base_v2.py
neutron/plugins/ml2/driver_api.py
neutron/plugins/ml2/managers.py
neutron/plugins/ml2/plugin.py
neutron/server/__init__.py
neutron/service.py
neutron/services/l3_router/l3_router_plugin.py
neutron/services/service_base.py
neutron/tests/functional/test_server.py
neutron/worker.py [new file with mode: 0644]
neutron/wsgi.py