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