@@ -990,12 +990,32 @@ merge_feature_flags(FeatureFlagsA, FeatureFlagsB) ->
990990 FeatureFlags = maps :merge (FeatureFlagsA , FeatureFlagsB ),
991991 maps :map (
992992 fun (FeatureName , FeatureProps ) ->
993- FeaturePropsA = maps :get (FeatureName , FeatureFlagsA , #{}),
994- FeaturePropsB = maps :get (FeatureName , FeatureFlagsB , #{}),
993+ % % When we collect feature flag properties from all nodes, we
994+ % % start with an empty cluster inventory (a common Erlang
995+ % % recursion pattern). This means that all feature flags are
996+ % % unknown at first.
997+ % %
998+ % % Here we must compute a global stability level for each
999+ % % feature flag, in case all nodes are not on the same page
1000+ % % (like one nodes considers a feature flag experimental, but
1001+ % % another one marks it as stable). That's why we rank stability
1002+ % % level: required > stable > experimental.
1003+ % %
1004+ % % We must distinguish an unknown feature flag (they are all
1005+ % % unknown at the beginning of the collection) from a known
1006+ % % feature flags with no explicit stability level. In the latter
1007+ % % case, `rabbit_feature_flags:get_stability/1' will consider it
1008+ % % stable. However in the former case, we must consider it
1009+ % % experimental otherwise it would default to be stable would
1010+ % % superceed an experimental level, even though all nodes agree
1011+ % % on that level, because `rabbit_feature_flags:get_stability/1'
1012+ % % would return stable as well.
1013+ UnknownProps = #{stability => experimental },
1014+ FeaturePropsA = maps :get (
1015+ FeatureName , FeatureFlagsA , UnknownProps ),
1016+ FeaturePropsB = maps :get (
1017+ FeatureName , FeatureFlagsB , UnknownProps ),
9951018
996- % % There is a rank between stability levels. If a feature flag
997- % % is required somewhere, it is required globally. Otherwise if
998- % % it is stable somewhere, it is stable globally.
9991019 StabilityA = rabbit_feature_flags :get_stability (FeaturePropsA ),
10001020 StabilityB = rabbit_feature_flags :get_stability (FeaturePropsB ),
10011021 Stability = case {StabilityA , StabilityB } of
0 commit comments