NSX-v3 reinitialize cluster on fork
Changes the NSX v3 client clustering logic to listen for and handle neutron process create events which occur on api worker fork() calls. To handle; the cluster reinitialize it's structures and keepalive loops to ensure each api worker process maintains its own copy. backport: liberty Change-Id: I81c774be9351411e8dce8b8a3bde9ac0cacc40fa Closes-Bug: #1545051
This commit is contained in:
parent
32648b3832
commit
1225438f7c
@ -26,6 +26,9 @@ import urlparse
|
||||
|
||||
from eventlet import greenpool
|
||||
from eventlet import pools
|
||||
from neutron.callbacks import events
|
||||
from neutron.callbacks import registry
|
||||
from neutron.callbacks import resources
|
||||
from oslo_config import cfg
|
||||
from oslo_log import log
|
||||
from oslo_service import loopingcall
|
||||
@ -246,6 +249,21 @@ class ClusteredAPI(object):
|
||||
self._http_provider = http_provider
|
||||
self._keepalive_interval = keepalive_interval
|
||||
|
||||
def _init_cluster(*args, **kwargs):
|
||||
self._init_endpoints(providers,
|
||||
min_conns_per_pool, max_conns_per_pool)
|
||||
|
||||
_init_cluster()
|
||||
|
||||
# reinitialize upon fork for api workers to ensure each
|
||||
# process has its own keepalive loops + state
|
||||
registry.subscribe(
|
||||
_init_cluster, resources.PROCESS, events.AFTER_CREATE)
|
||||
|
||||
def _init_endpoints(self, providers,
|
||||
min_conns_per_pool, max_conns_per_pool):
|
||||
LOG.debug("Initializing API endpoints")
|
||||
|
||||
def _create_conn(p):
|
||||
def _conn():
|
||||
# called when a pool needs to create a new connection
|
||||
@ -270,7 +288,6 @@ class ClusteredAPI(object):
|
||||
for method in ClusteredAPI._HTTP_VERBS:
|
||||
setattr(self, method, self._proxy_stub(method))
|
||||
|
||||
LOG.debug("Initializing API endpoints")
|
||||
conns = greenpool.GreenPool()
|
||||
for endpoint in self._endpoints.values():
|
||||
conns.spawn(self._validate, endpoint)
|
||||
|
Loading…
x
Reference in New Issue
Block a user