refactor: remove relup revert callback functions

This commit is contained in:
Shawn 2024-07-23 10:50:09 +08:00
parent eb71477f43
commit 439abe430b
3 changed files with 37 additions and 29 deletions

View File

@ -16,23 +16,25 @@
-module(emqx_post_upgrade). -module(emqx_post_upgrade).
%% Example of a hot upgrade callback function.
%% PR#12765 %% PR#12765
% -export([ % -export([
% pr12765_update_stats_timer/1, % pr12765_update_stats_timer/1,
% pr12765_revert_stats_timer/1 % pr20000_ensure_sup_started/3
% ]). % ]).
-include("logger.hrl"). %% Please ensure that every callback function is reentrant.
%% This way, users can attempt upgrade multiple times if an issue arises.
%%------------------------------------------------------------------------------ %%
%% Hot Upgrade Callback Functions.
%%------------------------------------------------------------------------------
% pr12765_update_stats_timer(_FromVsn) -> % pr12765_update_stats_timer(_FromVsn) ->
% emqx_stats:update_interval(broker_stats, fun emqx_broker_helper:stats_fun/0). % emqx_stats:update_interval(broker_stats, fun emqx_broker_helper:stats_fun/0).
%
% pr12765_revert_stats_timer(_ToVsn) -> % pr20000_ensure_sup_started(_FromVsn, "5.6.1" ++ _, ChildSpec) ->
% emqx_stats:update_interval(broker_stats, fun emqx_broker:stats_fun/0). % ChildId = maps:get(id, ChildSpec),
% case supervisor:terminate_child(emqx_sup, ChildId) of
%%------------------------------------------------------------------------------ % ok -> supervisor:delete_child(emqx_sup, ChildId);
%% Helper functions % Error -> Error
%%------------------------------------------------------------------------------ % end,
% supervisor:start_child(emqx_sup, ChildSpec);
% pr20000_ensure_sup_started(_FromVsn, _TargetVsn, _) ->
% ok.

View File

@ -184,7 +184,7 @@ project_app_excluded("apps/" ++ AppStr, ExcludedApps) ->
plugins() -> plugins() ->
[ [
{emqx_relup, {git, "https://github.com/emqx/emqx-relup.git", {tag, "0.1.0"}}}, {emqx_relup, {git, "https://github.com/emqx/emqx-relup.git", {tag, "0.1.1"}}},
%% emqx main project does not require port-compiler %% emqx main project does not require port-compiler
%% pin at root level for deterministic %% pin at root level for deterministic
{pc, "v1.14.0"} {pc, "v1.14.0"}

View File

@ -8,31 +8,37 @@
%% Note that we do not support the 'apply' command in the 'code_changes' section. %% Note that we do not support the 'apply' command in the 'code_changes' section.
%% If any complex operations are needed during the upgrade process, please add %% If any complex operations are needed during the upgrade process, please add
%% them in the 'post_upgrade_callbacks' section, and implement them in the %% them in the 'post_upgrade_callbacks' section, and implement them in the
%% 'emqx_post_upgrade' module. %% 'emqx_post_upgrade' module. We consolidate the hot upgrade callback code into
%% a single module ('emqx_post_upgrade') is to avoid mixing the hot upgrade-related
%% code with the main logic code.
ChildSpec = fun(Mod) ->
#{
id => Mod,
start => {Mod, start_link, []},
restart => permanent,
shutdown => 5000,
type => worker,
modules => [Mod]
}
end.
#{ #{
target_version => "5.6.1+patch.A", target_version => "5.6.1+patch.A",
from_version => "5.6.1", from_version => "5.6.1",
code_changes => code_changes =>
%% the 'emqx_release' and 'emqx_post_upgrade' will be automatically added,
%% no need to include them here
[ {load_module, emqx_broker} [ {load_module, emqx_broker}
, {load_module, emqx_metrics} , {load_module, emqx_metrics}
, {load_module, emqx_persistent_message}
, {load_module, emqx_dashboard_monitor}
, {load_module, emqx_dashboard_monitor_api}
, {load_module, emqx_ds_builtin_metrics}
, {load_module, emqx_ds_storage_bitfield_lts}
, {load_module, emqx_prometheus}
, {load_module, emqx_ds_builtin_db_sup}
, {load_module, emqx_ds_builtin_sup}
, {load_module, emqx_ds_replication_layer}
, {load_module, emqx_ds_storage_layer}
, {load_module, emqx_broker_helper}
, {load_module, emqx_shared_sub}
, {load_module, emqx_ds_replication_shard_allocator} , {load_module, emqx_ds_replication_shard_allocator}
, {load_module, emqx_mgmt_api_metrics}
, {update, emqx_ds_replication_layer_egress, {advanced, #{}}} , {update, emqx_ds_replication_layer_egress, {advanced, #{}}}
], ],
post_upgrade_callbacks => post_upgrade_callbacks =>
[ {pr12765_update_stats_timer, pr12765_revert_stats_timer} [
%% emqx_post_upgrade:pr12765_update_stats_timer/1
pr12765_update_stats_timer,
%% emqx_post_upgrade:pr20000_ensure_sup_started/3
{pr20000_ensure_sup_started, ["5.6.1+patch.A", ChildSpec(some_mod)]}
] ]
}. }.