fix: /listeners API crash when some nodes still in init configuration
This commit is contained in:
parent
e8e23938a2
commit
386110ae1e
|
@ -7,6 +7,7 @@
|
|||
## Bug fixes
|
||||
|
||||
* Check ACLs for last will testament topic before publishing the message. [#8930](https://github.com/emqx/emqx/pull/8930)
|
||||
* Fix GET /listeners API crash When some nodes still in initial configuration. [#9002](https://github.com/emqx/emqx/pull/9002)
|
||||
|
||||
# 5.0.8
|
||||
|
||||
|
|
|
@ -87,12 +87,18 @@ format_list(Listener) ->
|
|||
].
|
||||
|
||||
do_list_raw() ->
|
||||
Key = <<"listeners">>,
|
||||
Raw = emqx_config:get_raw([Key], #{}),
|
||||
SchemaMod = emqx_config:get_schema_mod(Key),
|
||||
#{Key := RawWithDefault} = emqx_config:fill_defaults(SchemaMod, #{Key => Raw}, #{}),
|
||||
Listeners = maps:to_list(RawWithDefault),
|
||||
lists:flatmap(fun format_raw_listeners/1, Listeners).
|
||||
%% GET /listeners from other nodes returns [] when init config is not loaded.
|
||||
case emqx_app:get_init_config_load_done() of
|
||||
true ->
|
||||
Key = <<"listeners">>,
|
||||
Raw = emqx_config:get_raw([Key], #{}),
|
||||
SchemaMod = emqx_config:get_schema_mod(Key),
|
||||
#{Key := RawWithDefault} = emqx_config:fill_defaults(SchemaMod, #{Key => Raw}, #{}),
|
||||
Listeners = maps:to_list(RawWithDefault),
|
||||
lists:flatmap(fun format_raw_listeners/1, Listeners);
|
||||
false ->
|
||||
[]
|
||||
end.
|
||||
|
||||
format_raw_listeners({Type0, Conf}) ->
|
||||
Type = binary_to_atom(Type0),
|
||||
|
|
|
@ -152,11 +152,11 @@ copy_override_conf_from_core_node() ->
|
|||
_ ->
|
||||
[{ok, Info} | _] = lists:sort(fun conf_sort/2, Ready),
|
||||
#{node := Node, conf := RawOverrideConf, tnx_id := TnxId} = Info,
|
||||
Msg = #{
|
||||
?SLOG(debug, #{
|
||||
msg => "copy_overide_conf_from_core_node_success",
|
||||
node => Node
|
||||
},
|
||||
?SLOG(debug, Msg),
|
||||
node => Node,
|
||||
envs => application:get_all_env(emqx)
|
||||
}),
|
||||
ok = emqx_config:save_to_override_conf(
|
||||
RawOverrideConf,
|
||||
#{override_to => cluster}
|
||||
|
|
Loading…
Reference in New Issue