Merge remote-tracking branch 'jgras/topic/jgras/cluster-active-node-count-fix'

* jgras/topic/jgras/cluster-active-node-count-fix:
  Fix get_active_node_count for node types not present.

Changed over to explicit existence check instead to avoid the set()
creation upon missed lookups.
This commit is contained in:
Arne Welzel 2023-05-17 10:21:03 +02:00
commit c2a07476cc
3 changed files with 8 additions and 4 deletions

View file

@ -1,3 +1,7 @@
6.0.0-dev.595 | 2023-05-17 10:36:22 +0200
* Fix get_active_node_count for node types not present. (Jan Grashoefer, Corelight)
6.0.0-dev.592 | 2023-05-17 09:02:09 +0200 6.0.0-dev.592 | 2023-05-17 09:02:09 +0200
* zeekygen: Render function parameters as :param x: instead of :x: (Arne Welzel, Corelight) * zeekygen: Render function parameters as :param x: instead of :x: (Arne Welzel, Corelight)

View file

@ -1 +1 @@
6.0.0-dev.592 6.0.0-dev.595

View file

@ -318,7 +318,7 @@ function Cluster::get_node_count(node_type: NodeType): count
function Cluster::get_active_node_count(node_type: NodeType): count function Cluster::get_active_node_count(node_type: NodeType): count
{ {
return |active_node_ids[node_type]|; return node_type in active_node_ids ? |active_node_ids[node_type]| : 0;
} }
function is_enabled(): bool function is_enabled(): bool
@ -377,7 +377,7 @@ event Cluster::hello(name: string, id: string) &priority=10
@pragma push ignore-deprecations @pragma push ignore-deprecations
if ( n$node_type == WORKER ) if ( n$node_type == WORKER )
worker_count = |active_node_ids[WORKER]|; worker_count = get_active_node_count(WORKER);
@pragma pop ignore-deprecations @pragma pop ignore-deprecations
} }
@ -402,7 +402,7 @@ event Broker::peer_lost(endpoint: Broker::EndpointInfo, msg: string) &priority=1
@pragma push ignore-deprecations @pragma push ignore-deprecations
if ( n$node_type == WORKER ) if ( n$node_type == WORKER )
worker_count = |active_node_ids[WORKER]|; worker_count = get_active_node_count(WORKER);
@pragma pop ignore-deprecations @pragma pop ignore-deprecations
event Cluster::node_down(node_name, endpoint$id); event Cluster::node_down(node_name, endpoint$id);