Remove pre-maintenance_mode_status compatibility code

Maintenance mode, introduced in RabbitMQ 3.8.x, was a breaking change
protected behind a feature flag. This allowed a RabbitMQ cluster to be
upgraded one node at a time, without having to stop the entire cluster.

The compatibility code is in the wild for long enough. The
`maintenance_mode_status` feature flag was marked as required in a
previous commit (see #5202). This allows us to remove code in this
patch.

References #5215.
This commit is contained in:
Jean-Sébastien Pédron 2022-07-15 17:23:18 +02:00
parent 454159bbd5
commit 43a525f4d0
No known key found for this signature in database
GPG Key ID: 39E99761A5FD94CC
1 changed files with 13 additions and 40 deletions

View File

@ -34,7 +34,6 @@
]).
-define(TABLE, rabbit_node_maintenance_states).
-define(FEATURE_FLAG, maintenance_mode_status).
-define(DEFAULT_STATUS, regular).
-define(DRAINING_STATUS, draining).
@ -55,26 +54,18 @@
{requires, networking}]}).
boot() ->
case rabbit_feature_flags:is_enabled(?FEATURE_FLAG, non_blocking) of
true ->
TableName = status_table_name(),
rabbit_log:info(
"Creating table ~s for feature flag `~s`",
[TableName, ?FEATURE_FLAG]),
try
_ = rabbit_table:create(
TableName,
status_table_definition())
catch throw:Reason ->
rabbit_log:error(
"Failed to create maintenance status table: ~p",
[Reason])
end;
false ->
ok;
state_changing ->
%% feature flag migration will do the job for us
ok
TableName = status_table_name(),
rabbit_log:info(
"Creating table ~s for maintenance mode status",
[TableName]),
try
_ = rabbit_table:create(
TableName,
status_table_definition())
catch throw:Reason ->
rabbit_log:error(
"Failed to create maintenance status table: ~p",
[Reason])
end.
%%
@ -94,19 +85,10 @@ status_table_definition() ->
-spec is_enabled() -> boolean().
is_enabled() ->
rabbit_feature_flags:is_enabled(?FEATURE_FLAG).
true.
-spec drain() -> ok.
drain() ->
case is_enabled() of
true -> do_drain();
false ->
rabbit_log:error("Feature flag '~s' is not enabled, cannot put this node under maintenance", [?FEATURE_FLAG]),
{error, rabbit_misc:format("Feature flag '~s' is not enabled, cannot put this node under maintenance", [?FEATURE_FLAG])}
end.
-spec do_drain() -> ok.
do_drain() ->
rabbit_log:warning("This node is being put into maintenance (drain) mode"),
mark_as_being_drained(),
rabbit_log:info("Marked this node as undergoing maintenance"),
@ -135,15 +117,6 @@ do_drain() ->
-spec revive() -> ok.
revive() ->
case is_enabled() of
true -> do_revive();
false ->
rabbit_log:error("Feature flag '~s' is not enabled, cannot put this node out of maintenance", [?FEATURE_FLAG]),
{error, rabbit_misc:format("Feature flag '~s' is not enabled, cannot put this node out of maintenance", [?FEATURE_FLAG])}
end.
-spec do_revive() -> ok.
do_revive() ->
rabbit_log:info("This node is being revived from maintenance (drain) mode"),
revive_local_quorum_queue_replicas(),
rabbit_log:info("Resumed all listeners and will accept client connections again"),