Skip to content

Use prelaunch context instead of reading app env. variable #10018

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions deps/rabbit/src/rabbit.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1175,8 +1175,13 @@ get_default_data_param(Param) ->
%% </ul>

data_dir() ->
{ok, DataDir} = application:get_env(rabbit, data_dir),
DataDir.
case rabbit_prelaunch:get_context() of
#{data_dir := DataDir} ->
DataDir;
_ ->
{ok, DataDir} = application:get_env(rabbit, data_dir),
DataDir
end.

%%---------------------------------------------------------------------------
%% logging
Expand Down
11 changes: 8 additions & 3 deletions deps/rabbit/src/rabbit_feature_flags.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1164,9 +1164,14 @@ delete_enabled_feature_flags_list_file() ->
%% @returns the path to the file.

enabled_feature_flags_list_file() ->
case application:get_env(rabbit, feature_flags_file) of
{ok, Val} -> Val;
undefined -> throw(feature_flags_file_not_set)
case rabbit_prelaunch:get_context() of
#{feature_flags_file := File} ->
File;
_ ->
case application:get_env(rabbit, feature_flags_file) of
{ok, Val} -> Val;
undefined -> throw(feature_flags_file_not_set)
end
end.

copy_feature_states_after_reset(RemoteNode) ->
Expand Down
6 changes: 4 additions & 2 deletions deps/rabbit/src/rabbit_ff_controller.erl
Original file line number Diff line number Diff line change
Expand Up @@ -670,8 +670,10 @@ get_forced_feature_flag_names_from_env() ->
%% @private

get_forced_feature_flag_names_from_config() ->
Value = application:get_env(
rabbit, forced_feature_flags_on_init, undefined),
Value = maps:get(
forced_feature_flags_on_init,
rabbit_prelaunch:get_context(),
undefined),
case Value of
undefined ->
Value;
Expand Down
46 changes: 29 additions & 17 deletions deps/rabbit/src/rabbit_plugins.erl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ ensure(FileJustChanged) ->
end.

ensure1(FileJustChanged0) ->
{ok, OurFile0} = application:get_env(rabbit, enabled_plugins_file),
OurFile0 = enabled_plugins_file(),
FileJustChanged = filename:nativename(FileJustChanged0),
OurFile = filename:nativename(OurFile0),
case OurFile of
Expand Down Expand Up @@ -72,39 +72,51 @@ ensure1(FileJustChanged0) ->

-spec plugins_expand_dir() -> file:filename().
plugins_expand_dir() ->
case application:get_env(rabbit, plugins_expand_dir) of
{ok, ExpandDir} ->
case rabbit_prelaunch:get_context() of
#{plugins_expand_dir := ExpandDir} ->
ExpandDir;
_ ->
filename:join([rabbit:data_dir(), "plugins_expand_dir"])
case application:get_env(rabbit, plugins_expand_dir) of
{ok, ExpandDir} ->
ExpandDir;
undefined ->
filename:join([rabbit:data_dir(), "plugins_expand_dir"])
end
end.

-spec plugins_dir() -> file:filename().
plugins_dir() ->
case application:get_env(rabbit, plugins_dir) of
{ok, PluginsDistDir} ->
case rabbit_prelaunch:get_context() of
#{plugins_path := PluginsDistDir} ->
PluginsDistDir;
_ ->
filename:join([rabbit:data_dir(), "plugins_dir_stub"])
case application:get_env(rabbit, plugins_dir) of
{ok, PluginsDistDir} ->
PluginsDistDir;
undefined ->
filename:join([rabbit:data_dir(), "plugins_dir_stub"])
end
end.

-spec enabled_plugins_file() -> file:filename().
enabled_plugins_file() ->
case application:get_env(rabbit, enabled_plugins_file) of
{ok, Val} ->
Val;
case rabbit_prelaunch:get_context() of
#{enabled_plugins_file := File} ->
File;
_ ->
filename:join([rabbit:data_dir(), "enabled_plugins"])
case application:get_env(rabbit, enabled_plugins_file) of
{ok, File} ->
File;
undefined ->
filename:join([rabbit:data_dir(), "enabled_plugins"])

end
end.

-spec enabled_plugins() -> [atom()].
enabled_plugins() ->
case application:get_env(rabbit, enabled_plugins_file) of
{ok, EnabledFile} ->
read_enabled(EnabledFile);
_ ->
[]
end.
EnabledFile = enabled_plugins_file(),
read_enabled(EnabledFile).

%% @doc Prepares the file system and installs all enabled plugins.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ i(net_ticktime, State) ->
i(persister_stats, State) ->
{State, persister_stats(State)};
i(enabled_plugins, State) ->
{ok, Dir} = application:get_env(rabbit, enabled_plugins_file),
Dir = rabbit_plugins:enabled_plugins_file(),
{State, rabbit_plugins:read_enabled(Dir)};
i(auth_mechanisms, State) ->
{ok, Mechanisms} = application:get_env(rabbit, auth_mechanisms),
Expand Down