2
0
mirror of https://github.com/xcat2/confluent.git synced 2026-09-29 00:31:09 +00:00

Background nodelist change handling

The discovery reaction to a node being deleted or added is laborious, and redundant.  Background
the handling and make sure only one instance executes and aggregate redundant rechecks to a single
re-execution at the end.
This commit is contained in:
Jarrod Johnson
2017-04-28 09:14:55 -04:00
parent 1d04405099
commit 60ec9c7c51
+20 -1
View File
@@ -579,17 +579,36 @@ def discover_node(cfg, handler, info, nodename):
attribwatcher = None
nodeaddhandler = None
needaddhandled = False
def _handle_nodelist_change(configmanager):
global needaddhandled
global nodeaddhandler
_recheck_nodes((), configmanager)
if needaddhandled:
needaddhandled = False
nodeaddhandler = eventlet.spawn(_handle_nodelist_change, configmanager)
else:
nodeaddhandler = None
def newnodes(added, deleting, configmanager):
global attribwatcher
global needaddhandled
global nodeaddhandler
configmanager.remove_watcher(attribwatcher)
allnodes = configmanager.list_nodes()
attribwatcher = configmanager.watch_attributes(
allnodes, ('discovery.policy', 'net.switch',
'hardwaremanagement.manager', 'net.switchport', 'id.uuid',
'pubkeys.tls_hardwaremanager'), _recheck_nodes)
_recheck_nodes((), configmanager)
if nodeaddhandler:
needaddhandled = True
else:
nodeaddhandler = eventlet.spawn(_handle_nodelist_change, configmanager)
rechecker = None