diff --git a/deps/rabbit/src/rabbit_khepri.erl b/deps/rabbit/src/rabbit_khepri.erl index 5308894982f5..345a16b08e1b 100644 --- a/deps/rabbit/src/rabbit_khepri.erl +++ b/deps/rabbit/src/rabbit_khepri.erl @@ -509,8 +509,21 @@ reset() -> %% @private force_reset() -> - DataDir = maps:get(data_dir, ra_system:fetch(coordination)), - ok = rabbit_file:recursive_delete(filelib:wildcard(DataDir ++ "/*")). + %% The Ra `coordination' system is stopped at this point; we assert that + %% with the `ra_system:fetch/1' call below. Therefore, we take the data + %% directory from the configuration. + RaSystem = coordination, + ?assertEqual(undefined, ra_system:fetch(RaSystem)), + Config = rabbit_ra_systems:get_config(RaSystem), + DataDir = maps:get(data_dir, Config), + ?assert(string:length(DataDir) > 0), %% Assertion to not `rm -rf /'. + ?LOG_INFO( + "Deleting Ra `coordination` system data directory as part of " + "Khepri reset: ~ts", + [DataDir], + #{domain => ?RMQLOG_DOMAIN_GLOBAL}), + Glob = filename:join(DataDir, "*"), + ok = rabbit_file:recursive_delete(filelib:wildcard(Glob)). %% @private diff --git a/deps/rabbit/src/rabbit_ra_systems.erl b/deps/rabbit/src/rabbit_ra_systems.erl index cf2a3b3ad95f..a3f0ade5dda2 100644 --- a/deps/rabbit/src/rabbit_ra_systems.erl +++ b/deps/rabbit/src/rabbit_ra_systems.erl @@ -13,6 +13,7 @@ -export([setup/0, setup/1, + get_config/1, all_ra_systems/0, are_running/0, ensure_ra_system_started/1,