Skip to content

Commit 4a63d66

Browse files
committed
Feature flags: Only enable stable feature flags on a virgin node
Before this change, all feature flags were enabled by default when a new node was started. Now, only the stable ones are enabled, not the experimental ones. In other words, experimental feature flags must be enabled explicitely.
1 parent 1649fcf commit 4a63d66

File tree

1 file changed

+19
-3
lines changed

1 file changed

+19
-3
lines changed

deps/rabbit/src/rabbit_feature_flags.erl

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@
8282
list/2,
8383
enable/1,
8484
enable_all/0,
85+
enable_all/1,
8586
disable/1,
8687
disable_all/0,
8788
is_supported/1,
@@ -338,6 +339,21 @@ enable(FeatureNames) when is_list(FeatureNames) ->
338339
enable_all() ->
339340
with_feature_flags(maps:keys(list(all)), fun enable/1).
340341

342+
-spec enable_all(stability()) -> ok | {error, any()}.
343+
%% @doc
344+
%% Enables all supported feature flags matching the given stability.
345+
%%
346+
%% @param Stability The level of stability used to filter the feature flags to
347+
%% enable.
348+
%% @returns `ok' if the feature flags were successfully enabled,
349+
%% or `{error, Reason}' if one feature flag could not be enabled
350+
%% (subsequent feature flags in the dependency tree are left
351+
%% unchanged).
352+
353+
enable_all(Stability)
354+
when Stability =:= stable orelse Stability =:= experimental ->
355+
with_feature_flags(maps:keys(list(all, Stability)), fun enable/1).
356+
341357
-spec disable(feature_name() | [feature_name()]) -> ok | {error, any()}.
342358
%% @doc
343359
%% Disables the specified feature flag or set of feature flags.
@@ -2087,9 +2103,9 @@ sync_feature_flags_with_cluster([], NodeIsVirgin, _) ->
20872103
[] when FeatureNames =:= undefined ->
20882104
rabbit_log_feature_flags:debug(
20892105
"Feature flags: starting an unclustered node "
2090-
"for the first time: all feature flags will be "
2091-
"enabled by default"),
2092-
enable_all();
2106+
"for the first time: all stable feature flags "
2107+
"will be enabled by default"),
2108+
enable_all(stable);
20932109
[] ->
20942110
case FeatureNames of
20952111
[] ->

0 commit comments

Comments
 (0)