fix: sync data's authz and certs
This commit is contained in:
parent
b134c3562a
commit
740ff3587c
|
@ -20,6 +20,7 @@
|
||||||
|
|
||||||
-export([start/2, stop/1]).
|
-export([start/2, stop/1]).
|
||||||
-export([get_override_config_file/0]).
|
-export([get_override_config_file/0]).
|
||||||
|
-export([sync_data_from_node/0]).
|
||||||
|
|
||||||
-include_lib("emqx/include/logger.hrl").
|
-include_lib("emqx/include/logger.hrl").
|
||||||
-include("emqx_conf.hrl").
|
-include("emqx_conf.hrl").
|
||||||
|
@ -56,6 +57,12 @@ get_override_config_file() ->
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
sync_data_from_node() ->
|
||||||
|
Dir = emqx:data_dir(),
|
||||||
|
{ok, Zip} = zip:zip(atom_to_list(node()) ++ "_data.zip", ["authz", "certs"], [{cwd, Dir}]),
|
||||||
|
Res = {ok, _Bin} = file:read_file(Zip),
|
||||||
|
Res.
|
||||||
|
|
||||||
%% ------------------------------------------------------------------------------
|
%% ------------------------------------------------------------------------------
|
||||||
%% Internal functions
|
%% Internal functions
|
||||||
%% ------------------------------------------------------------------------------
|
%% ------------------------------------------------------------------------------
|
||||||
|
@ -150,6 +157,7 @@ copy_override_conf_from_core_node() ->
|
||||||
RawOverrideConf,
|
RawOverrideConf,
|
||||||
#{override_to => cluster}
|
#{override_to => cluster}
|
||||||
),
|
),
|
||||||
|
ok = sync_data_from_node(Node),
|
||||||
{ok, TnxId}
|
{ok, TnxId}
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
@ -173,3 +181,14 @@ conf_sort({ok, #{tnx_id := Id, wall_clock := W1}}, {ok, #{tnx_id := Id, wall_clo
|
||||||
W1 > W2;
|
W1 > W2;
|
||||||
conf_sort({ok, _}, {ok, _}) ->
|
conf_sort({ok, _}, {ok, _}) ->
|
||||||
false.
|
false.
|
||||||
|
|
||||||
|
sync_data_from_node(Node) ->
|
||||||
|
case emqx_conf_proto_v1:sync_data_from_node(Node) of
|
||||||
|
{ok, DataBin} ->
|
||||||
|
{ok, Files} = zip:unzip(DataBin, [{cwd, emqx:data_dir()}]),
|
||||||
|
?SLOG(debug, #{node => Node, msg => "sync_data_from_node_ok", files => Files}),
|
||||||
|
ok;
|
||||||
|
Error ->
|
||||||
|
?SLOG(emergency, #{node => Node, msg => "sync_data_from_node_failed", reason => Error}),
|
||||||
|
error(Error)
|
||||||
|
end.
|
||||||
|
|
|
@ -33,7 +33,8 @@
|
||||||
reset/2,
|
reset/2,
|
||||||
reset/3,
|
reset/3,
|
||||||
|
|
||||||
get_override_config_file/1
|
get_override_config_file/1,
|
||||||
|
sync_data_from_node/1
|
||||||
]).
|
]).
|
||||||
|
|
||||||
-include_lib("emqx/include/bpapi.hrl").
|
-include_lib("emqx/include/bpapi.hrl").
|
||||||
|
@ -104,3 +105,7 @@ reset(Node, KeyPath, Opts) ->
|
||||||
-spec get_override_config_file([node()]) -> emqx_rpc:multicall_result().
|
-spec get_override_config_file([node()]) -> emqx_rpc:multicall_result().
|
||||||
get_override_config_file(Nodes) ->
|
get_override_config_file(Nodes) ->
|
||||||
rpc:multicall(Nodes, emqx_conf_app, get_override_config_file, [], 20000).
|
rpc:multicall(Nodes, emqx_conf_app, get_override_config_file, [], 20000).
|
||||||
|
|
||||||
|
-spec sync_data_from_node(node()) -> {ok, binary()} | emqx_rpc:badrpc().
|
||||||
|
sync_data_from_node(Node) ->
|
||||||
|
rpc:call(Node, emqx_conf_app, sync_data_from_node, [], 20000).
|
||||||
|
|
Loading…
Reference in New Issue