Skip to content

Commit f866f33

Browse files
committed
rabbit_deprecated_features: Use is_feature_used callback only if not required
[Why] The `is_feature_used` callback is used to determine if a deprecated feature can really be denied. Therefore it only makes sense for deprecated features in their `permitted_by_default` and `denied_by_default` phases. When a deprecated feature enters the `disconnected` or `removed` phases, the code being the feature should be gone. Therefore, there is no point in checking if it is used. [How] We get the stability derived from the deprecated feature phase before we actually run the callback. While here, if the callback returns an error, we treat it as if it returned that the feature is used. As a reminder, a node will refuse to start if a deprecated feature is denied but the feature is used. This is a slight change compared to the initial goal of the deprecated features subsystem. Indeed, the goal was to allow users experiment with the future behavior of RabbitMQ. However, a future node would probably still start even if there were left-overs from a removed feature. However if a `permitted_by_default` or `denied_by_default` deprecated feature is denied, the node would refuse to start. We see that as a strong way to communicate the user that an action is required from them.
1 parent 5ed5f8d commit f866f33

File tree

1 file changed

+17
-8
lines changed

1 file changed

+17
-8
lines changed

deps/rabbit/src/rabbit_ff_controller.erl

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1273,20 +1273,29 @@ list_feature_flags_enabled_somewhere(
12731273
FeatureName :: rabbit_feature_flags:feature_name().
12741274

12751275
list_deprecated_features_that_cant_be_denied(
1276-
#{states_per_node := StatesPerNode}) ->
1276+
#{feature_flags := FeatureFlags,
1277+
states_per_node := StatesPerNode}) ->
12771278
ThisNode = node(),
12781279
States = maps:get(ThisNode, StatesPerNode),
12791280

12801281
maps:fold(
12811282
fun
12821283
(FeatureName, true, Acc) ->
1283-
#{ThisNode := IsUsed} = run_callback(
1284-
[ThisNode], FeatureName,
1285-
is_feature_used, #{}, infinity),
1286-
case IsUsed of
1287-
true -> [FeatureName | Acc];
1288-
false -> Acc;
1289-
_Error -> Acc
1284+
FeatureProps = maps:get(FeatureName, FeatureFlags),
1285+
Stability = rabbit_feature_flags:get_stability(FeatureProps),
1286+
case Stability of
1287+
required ->
1288+
Acc;
1289+
_ ->
1290+
#{ThisNode := IsUsed} = run_callback(
1291+
[ThisNode], FeatureName,
1292+
is_feature_used, #{},
1293+
infinity),
1294+
case IsUsed of
1295+
true -> [FeatureName | Acc];
1296+
false -> Acc;
1297+
_Error -> [FeatureName | Acc]
1298+
end
12901299
end;
12911300
(_FeatureName, false, Acc) ->
12921301
Acc

0 commit comments

Comments
 (0)