Rename
This commit is contained in:
parent
2d2c70cc7c
commit
77cec4930e
|
@ -1652,7 +1652,7 @@ end}.
|
||||||
%% and refuse to start if the marker exists but tables are empty.
|
%% and refuse to start if the marker exists but tables are empty.
|
||||||
%%
|
%%
|
||||||
|
|
||||||
{mapping, "verify_initial_run", "rabbit.verify_initial_run", [
|
{mapping, "prevent_startup_if_node_was_reset", "rabbit.prevent_startup_if_node_was_reset", [
|
||||||
{datatype, {enum, [true, false]}}
|
{datatype, {enum, [true, false]}}
|
||||||
]}.
|
]}.
|
||||||
|
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
%% Boot steps.
|
%% Boot steps.
|
||||||
-export([update_cluster_tags/0, maybe_insert_default_data/0, boot_delegate/0, recover/0,
|
-export([update_cluster_tags/0, maybe_insert_default_data/0, boot_delegate/0, recover/0,
|
||||||
pg_local_amqp_session/0,
|
pg_local_amqp_session/0,
|
||||||
pg_local_amqp_connection/0, check_initial_run/0]).
|
pg_local_amqp_connection/0, prevent_startup_if_node_was_reset/0]).
|
||||||
|
|
||||||
-rabbit_boot_step({pre_boot, [{description, "rabbit boot start"}]}).
|
-rabbit_boot_step({pre_boot, [{description, "rabbit boot start"}]}).
|
||||||
|
|
||||||
|
@ -201,7 +201,7 @@
|
||||||
|
|
||||||
-rabbit_boot_step({initial_run_check,
|
-rabbit_boot_step({initial_run_check,
|
||||||
[{description, "check if this is the first time the node starts"},
|
[{description, "check if this is the first time the node starts"},
|
||||||
{mfa, {?MODULE, check_initial_run, []}},
|
{mfa, {?MODULE, prevent_startup_if_node_was_reset, []}},
|
||||||
{requires, recovery},
|
{requires, recovery},
|
||||||
{enables, empty_db_check}]}).
|
{enables, empty_db_check}]}).
|
||||||
|
|
||||||
|
@ -1159,13 +1159,13 @@ update_cluster_tags() ->
|
||||||
rabbit_runtime_parameters:set_global(cluster_tags, Tags, <<"internal_user">>).
|
rabbit_runtime_parameters:set_global(cluster_tags, Tags, <<"internal_user">>).
|
||||||
|
|
||||||
|
|
||||||
-spec check_initial_run() -> 'ok' | no_return().
|
-spec prevent_startup_if_node_was_reset() -> 'ok' | no_return().
|
||||||
|
|
||||||
check_initial_run() ->
|
prevent_startup_if_node_was_reset() ->
|
||||||
case application:get_env(rabbit, verify_initial_run, false) of
|
case application:get_env(rabbit, prevent_startup_if_node_was_reset, false) of
|
||||||
false ->
|
false ->
|
||||||
%% Feature is disabled, skip the check
|
%% Feature is disabled, skip the check
|
||||||
?LOG_DEBUG("Initial run verification is disabled",
|
?LOG_DEBUG("prevent_startup_if_node_was_reset is disabled",
|
||||||
#{domain => ?RMQLOG_DOMAIN_GLOBAL}),
|
#{domain => ?RMQLOG_DOMAIN_GLOBAL}),
|
||||||
ok;
|
ok;
|
||||||
true ->
|
true ->
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
%% Copyright (c) 2007-2024 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
|
%% Copyright (c) 2007-2024 Broadcom. All Rights Reserved. The term "Broadcom" refers to Broadcom Inc. and/or its subsidiaries. All rights reserved.
|
||||||
%%
|
%%
|
||||||
|
|
||||||
%% Test suite for the verify_initial_run feature.
|
%% Test suite for the prevent_startup_if_node_was_reset feature.
|
||||||
%% This feature helps detect potential data loss scenarios by maintaining
|
%% This feature helps detect potential data loss scenarios by maintaining
|
||||||
%% a marker file to track if a node has been initialized before.
|
%% a marker file to track if a node has been initialized before.
|
||||||
|
|
||||||
|
@ -25,12 +25,12 @@ all() ->
|
||||||
groups() ->
|
groups() ->
|
||||||
[
|
[
|
||||||
{single_node_mnesia, [], [
|
{single_node_mnesia, [], [
|
||||||
verify_initial_run_disabled,
|
prevent_startup_if_node_was_reset_disabled,
|
||||||
verify_initial_run_enabled
|
prevent_startup_if_node_was_reset_enabled
|
||||||
]},
|
]},
|
||||||
{single_node_khepri, [], [
|
{single_node_khepri, [], [
|
||||||
verify_initial_run_disabled,
|
prevent_startup_if_node_was_reset_disabled,
|
||||||
verify_initial_run_enabled
|
prevent_startup_if_node_was_reset_enabled
|
||||||
]}
|
]}
|
||||||
].
|
].
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ end_per_testcase(Testcase, Config) ->
|
||||||
%% Test cases
|
%% Test cases
|
||||||
%% -------------------------------------------------------------------
|
%% -------------------------------------------------------------------
|
||||||
|
|
||||||
verify_initial_run_disabled(Config) ->
|
prevent_startup_if_node_was_reset_disabled(Config) ->
|
||||||
% When feature is disabled (default), node should start normally
|
% When feature is disabled (default), node should start normally
|
||||||
DataDir = rabbit_ct_broker_helpers:get_node_config(Config, 0, data_dir),
|
DataDir = rabbit_ct_broker_helpers:get_node_config(Config, 0, data_dir),
|
||||||
MarkerFile = filename:join(DataDir, "node_initialized.marker"),
|
MarkerFile = filename:join(DataDir, "node_initialized.marker"),
|
||||||
|
@ -91,7 +91,7 @@ verify_initial_run_disabled(Config) ->
|
||||||
?assertNot(filelib:is_file(MarkerFile)),
|
?assertNot(filelib:is_file(MarkerFile)),
|
||||||
ok.
|
ok.
|
||||||
|
|
||||||
verify_initial_run_enabled(Config) ->
|
prevent_startup_if_node_was_reset_enabled(Config) ->
|
||||||
DataDir = rabbit_ct_broker_helpers:get_node_config(Config, 0, data_dir),
|
DataDir = rabbit_ct_broker_helpers:get_node_config(Config, 0, data_dir),
|
||||||
MarkerFile = filename:join(DataDir, "node_initialized.marker"),
|
MarkerFile = filename:join(DataDir, "node_initialized.marker"),
|
||||||
|
|
||||||
|
@ -140,11 +140,11 @@ start_app(Config) ->
|
||||||
Error -> Error
|
Error -> Error
|
||||||
end.
|
end.
|
||||||
|
|
||||||
maybe_enable_verify_initial_run(Config, verify_initial_run_enabled) ->
|
maybe_enable_prevent_startup_if_node_was_reset(Config, prevent_startup_if_node_was_reset_enabled) ->
|
||||||
rabbit_ct_helpers:merge_app_env(
|
rabbit_ct_helpers:merge_app_env(
|
||||||
Config, {rabbit, [{verify_initial_run, true}]}
|
Config, {rabbit, [{prevent_startup_if_node_was_reset, true}]}
|
||||||
);
|
);
|
||||||
maybe_enable_verify_initial_run(Config, _) ->
|
maybe_enable_prevent_startup_if_node_was_reset(Config, _) ->
|
||||||
Config.
|
Config.
|
||||||
|
|
||||||
meta_store(single_node_mnesia) ->
|
meta_store(single_node_mnesia) ->
|
||||||
|
@ -165,4 +165,4 @@ schema_file(Config) ->
|
||||||
|
|
||||||
set_env(Config, Bool) ->
|
set_env(Config, Bool) ->
|
||||||
Node = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
|
Node = rabbit_ct_broker_helpers:get_node_config(Config, 0, nodename),
|
||||||
ok = rpc:call(Node, application, set_env, [rabbit, verify_initial_run, Bool]).
|
ok = rpc:call(Node, application, set_env, [rabbit, prevent_startup_if_node_was_reset, Bool]).
|
||||||
|
|
Loading…
Reference in New Issue