From 18d265cecde6165f6581b050a967bd2e7cafb404 Mon Sep 17 00:00:00 2001 From: JianBo He Date: Thu, 12 May 2022 15:33:27 +0800 Subject: [PATCH 1/4] chore(gw): increase timeout to update gateway instance --- apps/emqx_gateway/src/emqx_gateway_insta_sup.erl | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/emqx_gateway/src/emqx_gateway_insta_sup.erl b/apps/emqx_gateway/src/emqx_gateway_insta_sup.erl index 50b7433cf..a065ea8fd 100644 --- a/apps/emqx_gateway/src/emqx_gateway_insta_sup.erl +++ b/apps/emqx_gateway/src/emqx_gateway_insta_sup.erl @@ -87,7 +87,9 @@ update(Pid, Config) -> call(Pid, {update, Config}). call(Pid, Req) -> - gen_server:call(Pid, Req, 5000). + %% The large timeout aim to get the modified results of the dependent + %% resources + gen_server:call(Pid, Req, 15000). %%-------------------------------------------------------------------- %% gen_server callbacks From ebe8b3fd20ab4c2cb9680ff4ed4dae6ffcbdf3eb Mon Sep 17 00:00:00 2001 From: JianBo He Date: Thu, 12 May 2022 15:34:02 +0800 Subject: [PATCH 2/4] chore(gw): pretty print exproto logs --- apps/emqx_gateway/src/exproto/emqx_exproto_impl.erl | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/apps/emqx_gateway/src/exproto/emqx_exproto_impl.erl b/apps/emqx_gateway/src/exproto/emqx_exproto_impl.erl index 7311ed310..9965956f7 100644 --- a/apps/emqx_gateway/src/exproto/emqx_exproto_impl.erl +++ b/apps/emqx_gateway/src/exproto/emqx_exproto_impl.erl @@ -167,16 +167,17 @@ start_grpc_server(GwName, Options = #{bind := ListenOn}) -> )} ] end, + ListenOnStr = emqx_listeners:format_addr(ListenOn), case grpc:start_server(GwName, ListenOn, Services, SvrOptions) of {ok, _SvrPid} -> console_print( - "Start ~ts gRPC server on ~p successfully.~n", - [GwName, ListenOn] + "Start ~ts gRPC server on ~s successfully.~n", + [GwName, ListenOnStr] ); {error, Reason} -> ?ELOG( - "Failed to start ~ts gRPC server on ~p, reason: ~0p", - [GwName, ListenOn, Reason] + "Failed to start ~ts gRPC server on ~s, reason: ~0p", + [GwName, ListenOnStr, Reason] ), throw( {badconf, #{ From 1867b86badf71b7cf44fca1fe683efc5c811ab2b Mon Sep 17 00:00:00 2001 From: JianBo He Date: Thu, 12 May 2022 18:01:10 +0800 Subject: [PATCH 3/4] fix(mgmt): return null instead of "undefined" string --- .../src/emqx_mgmt_api_clients.erl | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/apps/emqx_management/src/emqx_mgmt_api_clients.erl b/apps/emqx_management/src/emqx_mgmt_api_clients.erl index c7ceb26d5..bc27dc777 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_clients.erl +++ b/apps/emqx_management/src/emqx_mgmt_api_clients.erl @@ -862,10 +862,12 @@ format_channel_info({_, ClientInfo0, ClientStats}) -> ], TimesKeys = [created_at, connected_at, disconnected_at], %% format timestamp to rfc3339 - lists:foldl( - fun result_format_time_fun/2, - maps:without(RemoveList, ClientInfoMap), - TimesKeys + result_format_undefined_to_null( + lists:foldl( + fun result_format_time_fun/2, + maps:without(RemoveList, ClientInfoMap), + TimesKeys + ) ). %% format func helpers @@ -884,6 +886,15 @@ result_format_time_fun(Key, NClientInfoMap) -> NClientInfoMap end. +result_format_undefined_to_null(Map) -> + maps:map( + fun + (_, undefined) -> null; + (_, V) -> V + end, + Map + ). + -spec peername_dispart(emqx_types:peername()) -> {binary(), inet:port_number()}. peername_dispart({Addr, Port}) -> AddrBinary = list_to_binary(inet:ntoa(Addr)), From 3f846004014e566b28b17baa09658bccacbf1e9e Mon Sep 17 00:00:00 2001 From: JianBo He Date: Thu, 12 May 2022 20:27:25 +0800 Subject: [PATCH 4/4] test(gw): remove enable option from server ssl conf --- apps/emqx_gateway/test/emqx_gateway_api_SUITE.erl | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/apps/emqx_gateway/test/emqx_gateway_api_SUITE.erl b/apps/emqx_gateway/test/emqx_gateway_api_SUITE.erl index ff1606435..141eca3fe 100644 --- a/apps/emqx_gateway/test/emqx_gateway_api_SUITE.erl +++ b/apps/emqx_gateway/test/emqx_gateway_api_SUITE.erl @@ -211,9 +211,7 @@ t_gateway_exproto_with_ssl(_) -> name => <<"exproto">>, server => #{ bind => <<"9100">>, - ssl => SslSvrOpts#{ - enable => true - } + ssl => SslSvrOpts }, handler => #{ address => <<"http://127.0.0.1:9001">>, @@ -230,7 +228,7 @@ t_gateway_exproto_with_ssl(_) -> GwConf2 = emqx_map_lib:deep_merge(GwConf, #{ server => #{ bind => <<"9200">>, - ssl => SslCliOpts#{enable => true} + ssl => SslCliOpts } }), {200, _} = request(put, "/gateway/exproto", maps:without([name, listeners], GwConf2)),