scripts/base/cluster: Move active node management into node_down()

With the idea of an alternative cluster backend, we should
not maintain Cluster state within low-level Broker events.
This commit is contained in:
Arne Welzel 2024-03-02 23:06:37 +01:00
parent 78999d147d
commit 6bb7b9d726

View file

@ -401,16 +401,32 @@ event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string) &priority=1
{
if ( n?$id && n$id == endpoint$id )
{
Cluster::log(fmt("node down: %s", node_name));
delete n$id;
delete active_node_ids[n$node_type][endpoint$id];
event Cluster::node_down(node_name, endpoint$id);
break;
}
}
}
event node_down(name: string, id: string) &priority=10
{
local found = F;
for ( node_name, n in nodes )
{
if ( n?$id && n$id == id )
{
Cluster::log(fmt("node down: %s", node_name));
delete n$id;
delete active_node_ids[n$node_type][id];
found = T;
break;
}
}
if ( ! found )
Reporter::error(fmt("No node found in Cluster::node_down() node:%s id:%s",
name, id));
}
event zeek_init() &priority=5
{
# If a node is given, but it's an unknown name we need to fail.