fix(emqx_management): Ignore results from the nodes that are down

This commit is contained in:
ieQu1 2023-04-11 13:59:08 +02:00
parent 37c0badb06
commit a947df1ea3
2 changed files with 19 additions and 4 deletions

View File

@ -127,10 +127,19 @@ list(get, #{query_string := Qs}) ->
true ->
{200, emqx_mgmt:get_stats()};
_ ->
Data = [
maps:from_list(emqx_mgmt:get_stats(Node) ++ [{node, Node}])
|| Node <- running_nodes()
],
Data = lists:foldl(
fun(Node, Acc) ->
case emqx_mgmt:get_stats(Node) of
{error, _Err} ->
Acc;
Stats when is_list(Stats) ->
Data = maps:from_list([{node, Node} | Stats]),
[Data | Acc]
end
end,
[],
mria:running_nodes()
),
{200, Data}
end.

View File

@ -0,0 +1,6 @@
Fix error `/api/v5/monitor_current` API endpoint when some EMQX nodes are down.
Prior to this fix, sometimes the request returned HTTP code 500 and the following message:
```
{"code":"INTERNAL_ERROR","message":"error, badarg, [{erlang,'++',[{error,nodedown},[{node,'emqx@10.42.0.150'}]], ...
```