Merge pull request #6505 from JimMoen/v4.x-fix-node-info-format

fix(mgmt): fix node info format for specific node
This commit is contained in:
JimMoen 2021-12-31 13:39:43 +08:00 committed by GitHub
commit bec742b1be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 5 deletions

View File

@ -1,6 +1,6 @@
{application, emqx_management, {application, emqx_management,
[{description, "EMQ X Management API and CLI"}, [{description, "EMQ X Management API and CLI"},
{vsn, "4.3.9"}, % strict semver, bump manually! {vsn, "4.3.10"}, % strict semver, bump manually!
{modules, []}, {modules, []},
{registered, [emqx_management_sup]}, {registered, [emqx_management_sup]},
{applications, [kernel,stdlib,minirest]}, {applications, [kernel,stdlib,minirest]},

View File

@ -1,13 +1,13 @@
%% -*- mode: erlang -*- %% -*- mode: erlang -*-
{VSN, {VSN,
[ {<<"4\\.3\\.[0-8]+">>, [ {<<"4\\.3\\.[0-9]+">>,
[ {apply,{minirest,stop_http,['http:management']}}, [ {apply,{minirest,stop_http,['http:management']}},
{apply,{minirest,stop_http,['https:management']}}, {apply,{minirest,stop_http,['https:management']}},
{restart_application, emqx_management} {restart_application, emqx_management}
]}, ]},
{<<".*">>, []} {<<".*">>, []}
], ],
[ {<<"4\\.3\\.[0-8]+">>, [ {<<"4\\.3\\.[0-9]+">>,
[ {apply,{minirest,stop_http,['http:management']}}, [ {apply,{minirest,stop_http,['http:management']}},
{apply,{minirest,stop_http,['https:management']}}, {apply,{minirest,stop_http,['https:management']}},
{restart_application, emqx_management} {restart_application, emqx_management}

View File

@ -36,11 +36,10 @@ list(_Bindings, _Params) ->
minirest:return({ok, [format(Node, Info) || {Node, Info} <- emqx_mgmt:list_nodes()]}). minirest:return({ok, [format(Node, Info) || {Node, Info} <- emqx_mgmt:list_nodes()]}).
get(#{node := Node}, _Params) -> get(#{node := Node}, _Params) ->
minirest:return({ok, emqx_mgmt:lookup_node(Node)}). minirest:return({ok, format(Node, emqx_mgmt:lookup_node(Node))}).
format(Node, {error, Reason}) -> #{node => Node, error => Reason}; format(Node, {error, Reason}) -> #{node => Node, error => Reason};
format(_Node, Info = #{memory_total := Total, memory_used := Used}) -> format(_Node, Info = #{memory_total := Total, memory_used := Used}) ->
Info#{memory_total := emqx_mgmt_util:kmg(Total), Info#{memory_total := emqx_mgmt_util:kmg(Total),
memory_used := emqx_mgmt_util:kmg(Used)}. memory_used := emqx_mgmt_util:kmg(Used)}.