fix: mark fresh install to cp the default configuration file directly
This commit is contained in:
parent
95d387a790
commit
19e039e0d2
|
@ -59,7 +59,6 @@
|
||||||
-define(VSN_WILDCARD, "-*.tar.gz").
|
-define(VSN_WILDCARD, "-*.tar.gz").
|
||||||
|
|
||||||
-define(CONTENT_PLUGIN, plugin).
|
-define(CONTENT_PLUGIN, plugin).
|
||||||
-define(CONTENT_CONFIG, config).
|
|
||||||
|
|
||||||
namespace() ->
|
namespace() ->
|
||||||
"plugins".
|
"plugins".
|
||||||
|
@ -565,6 +564,7 @@ install_package(FileName, Bin) ->
|
||||||
ok = filelib:ensure_dir(File),
|
ok = filelib:ensure_dir(File),
|
||||||
ok = file:write_file(File, Bin),
|
ok = file:write_file(File, Bin),
|
||||||
PackageName = string:trim(FileName, trailing, ".tar.gz"),
|
PackageName = string:trim(FileName, trailing, ".tar.gz"),
|
||||||
|
put(?fresh_install, true),
|
||||||
case emqx_plugins:ensure_installed(PackageName) of
|
case emqx_plugins:ensure_installed(PackageName) of
|
||||||
{error, #{reason := not_found}} = NotFound ->
|
{error, #{reason := not_found}} = NotFound ->
|
||||||
NotFound;
|
NotFound;
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
|
|
||||||
-define(plugin_conf_not_found, plugin_conf_not_found).
|
-define(plugin_conf_not_found, plugin_conf_not_found).
|
||||||
-define(plugin_without_config_schema, plugin_without_config_schema).
|
-define(plugin_without_config_schema, plugin_without_config_schema).
|
||||||
|
-define(fresh_install, fresh_install).
|
||||||
|
|
||||||
-type schema_name() :: binary().
|
-type schema_name() :: binary().
|
||||||
-type avsc_path() :: string().
|
-type avsc_path() :: string().
|
||||||
|
|
|
@ -1233,9 +1233,18 @@ maybe_ensure_plugin_config(NameVsn) ->
|
||||||
|
|
||||||
-spec ensure_plugin_config(name_vsn()) -> ok.
|
-spec ensure_plugin_config(name_vsn()) -> ok.
|
||||||
ensure_plugin_config(NameVsn) ->
|
ensure_plugin_config(NameVsn) ->
|
||||||
|
case get(?fresh_install) of
|
||||||
|
true ->
|
||||||
|
?SLOG(debug, #{
|
||||||
|
msg => "default_plugin_config_used",
|
||||||
|
name_vsn => NameVsn,
|
||||||
|
reason => "fresh_install"
|
||||||
|
}),
|
||||||
|
cp_default_config_file(NameVsn);
|
||||||
|
_ ->
|
||||||
%% fetch plugin hocon config from cluster
|
%% fetch plugin hocon config from cluster
|
||||||
Nodes = [N || N <- mria:running_nodes(), N /= node()],
|
ensure_plugin_config(NameVsn, [N || N <- mria:running_nodes(), N /= node()])
|
||||||
ensure_plugin_config(NameVsn, Nodes).
|
end.
|
||||||
|
|
||||||
-spec ensure_plugin_config(name_vsn(), list()) -> ok.
|
-spec ensure_plugin_config(name_vsn(), list()) -> ok.
|
||||||
ensure_plugin_config(NameVsn, []) ->
|
ensure_plugin_config(NameVsn, []) ->
|
||||||
|
@ -1255,8 +1264,6 @@ ensure_plugin_config(NameVsn, Nodes) ->
|
||||||
ensure_config_map(NameVsn);
|
ensure_config_map(NameVsn);
|
||||||
_ ->
|
_ ->
|
||||||
?SLOG(error, #{msg => "config_not_found_from_cluster", name_vsn => NameVsn}),
|
?SLOG(error, #{msg => "config_not_found_from_cluster", name_vsn => NameVsn}),
|
||||||
%% otherwise cp default hocon file
|
|
||||||
%% i.e. Clean installation
|
|
||||||
cp_default_config_file(NameVsn)
|
cp_default_config_file(NameVsn)
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue