Procházet zdrojové kódy

fix(mria): Reserve replicant role for EE only

ieQu1 před 1 rokem
rodič
revize
9da744c423

+ 1 - 13
apps/emqx_conf/src/emqx_conf_schema.erl

@@ -194,18 +194,6 @@ fields("cluster") ->
                     'readOnly' => true
                 }
             )},
-        {"core_nodes",
-            sc(
-                node_array(),
-                #{
-                    %% This config is nerver needed (since 5.0.0)
-                    importance => ?IMPORTANCE_HIDDEN,
-                    mapping => "mria.core_nodes",
-                    default => [],
-                    'readOnly' => true,
-                    desc => ?DESC(db_core_nodes)
-                }
-            )},
         {"autoclean",
             sc(
                 emqx_schema:duration(),
@@ -600,7 +588,7 @@ fields("node") ->
             )},
         {"role",
             sc(
-                hoconsc:enum([core, replicant]),
+                hoconsc:enum([core] ++ emqx_schema_hooks:injection_point('node.role')),
                 #{
                     mapping => "mria.node_role",
                     default => core,

+ 7 - 1
apps/emqx_conf/src/emqx_conf_schema_inject.erl

@@ -22,12 +22,18 @@ schemas() ->
     schemas(emqx_release:edition()).
 
 schemas(Edition) ->
-    auth_ext(Edition) ++
+    mria(Edition) ++
+        auth_ext(Edition) ++
         cluster_linking(Edition) ++
         authn(Edition) ++
         authz() ++
         customized(Edition).
 
+mria(ce) ->
+    [];
+mria(ee) ->
+    [emqx_enterprise_schema].
+
 auth_ext(ce) ->
     [];
 auth_ext(ee) ->

+ 6 - 12
apps/emqx_conf/test/emqx_conf_schema_tests.erl

@@ -32,7 +32,6 @@
                 name = emqxcl
                 discovery_strategy = static
                 static.seeds = ~p
-                core_nodes = ~p
              }
     ").
 
@@ -41,7 +40,7 @@ array_nodes_test() ->
     ExpectNodes = ['emqx1@127.0.0.1', 'emqx2@127.0.0.1'],
     lists:foreach(
         fun(Nodes) ->
-            ConfFile = to_bin(?BASE_CONF, [Nodes, Nodes]),
+            ConfFile = to_bin(?BASE_CONF, [Nodes]),
             {ok, Conf} = hocon:binary(ConfFile, #{format => richmap}),
             ConfList = hocon_tconf:generate(emqx_conf_schema, Conf),
             VMArgs = proplists:get_value(vm_args, ConfList),
@@ -57,11 +56,6 @@ array_nodes_test() ->
                 {static, [{seeds, ExpectNodes}]},
                 ClusterDiscovery,
                 Nodes
-            ),
-            ?assertEqual(
-                ExpectNodes,
-                proplists:get_value(core_nodes, proplists:get_value(mria, ConfList)),
-                Nodes
             )
         end,
         [["emqx1@127.0.0.1", "emqx2@127.0.0.1"], "emqx1@127.0.0.1, emqx2@127.0.0.1"]
@@ -158,7 +152,7 @@ outdated_log_test() ->
 
 validate_log(Conf) ->
     ensure_acl_conf(),
-    BaseConf = to_bin(?BASE_CONF, ["emqx1@127.0.0.1", "emqx1@127.0.0.1"]),
+    BaseConf = to_bin(?BASE_CONF, ["emqx1@127.0.0.1"]),
     Conf0 = <<BaseConf/binary, (list_to_binary(Conf))/binary>>,
     {ok, ConfMap0} = hocon:binary(Conf0, #{format => richmap}),
     ConfList = hocon_tconf:generate(emqx_conf_schema, ConfMap0),
@@ -214,7 +208,7 @@ validate_log(Conf) ->
 
 file_log_infinity_rotation_size_test_() ->
     ensure_acl_conf(),
-    BaseConf = to_bin(?BASE_CONF, ["emqx1@127.0.0.1", "emqx1@127.0.0.1"]),
+    BaseConf = to_bin(?BASE_CONF, ["emqx1@127.0.0.1"]),
     Gen = fun(#{count := Count, size := Size}) ->
         Conf0 = to_bin(?FILE_LOG_BASE_CONF, [Count, Size]),
         Conf1 = [BaseConf, Conf0],
@@ -292,7 +286,7 @@ log_rotation_count_limit_test() ->
     rotation_size = \"1024MB\"
     }
     ",
-    BaseConf = to_bin(?BASE_CONF, ["emqx1@127.0.0.1", "emqx1@127.0.0.1"]),
+    BaseConf = to_bin(?BASE_CONF, ["emqx1@127.0.0.1"]),
     lists:foreach(fun({Conf, Count}) ->
         Conf0 = <<BaseConf/binary, Conf/binary>>,
         {ok, ConfMap0} = hocon:binary(Conf0, #{format => richmap}),
@@ -352,7 +346,7 @@ log_rotation_count_limit_test() ->
 
 authn_validations_test() ->
     ensure_acl_conf(),
-    BaseConf = to_bin(?BASE_CONF, ["emqx1@127.0.0.1", "emqx1@127.0.0.1"]),
+    BaseConf = to_bin(?BASE_CONF, ["emqx1@127.0.0.1"]),
 
     OKHttps = to_bin(?BASE_AUTHN_ARRAY, [post, true, <<"https://127.0.0.1:8080">>]),
     Conf0 = <<BaseConf/binary, OKHttps/binary>>,
@@ -410,7 +404,7 @@ authn_validations_test() ->
 
 listeners_test() ->
     ensure_acl_conf(),
-    BaseConf = to_bin(?BASE_CONF, ["emqx1@127.0.0.1", "emqx1@127.0.0.1"]),
+    BaseConf = to_bin(?BASE_CONF, ["emqx1@127.0.0.1"]),
 
     Conf = <<BaseConf/binary, ?LISTENERS>>,
     {ok, ConfMap0} = hocon:binary(Conf, #{format => richmap}),

+ 1 - 1
apps/emqx_enterprise/src/emqx_enterprise.app.src

@@ -1,6 +1,6 @@
 {application, emqx_enterprise, [
     {description, "EMQX Enterprise Edition"},
-    {vsn, "0.2.2"},
+    {vsn, "0.2.3"},
     {registered, []},
     {applications, [
         kernel,

+ 7 - 0
apps/emqx_enterprise/src/emqx_enterprise_schema.erl

@@ -5,12 +5,14 @@
 -module(emqx_enterprise_schema).
 
 -behaviour(hocon_schema).
+-behaviour(emqx_schema_hooks).
 
 -include_lib("typerefl/include/types.hrl").
 -include_lib("hocon/include/hoconsc.hrl").
 
 -export([namespace/0, roots/0, fields/1, translations/0, translation/1, desc/1, validations/0]).
 -export([upgrade_raw_conf/1]).
+-export([injected_fields/0]).
 
 -define(EE_SCHEMA_MODULES, [
     emqx_license_schema,
@@ -127,6 +129,11 @@ desc(Name) ->
 validations() ->
     emqx_conf_schema:validations() ++ emqx_license_schema:validations().
 
+injected_fields() ->
+    #{
+        'node.role' => [replicant]
+    }.
+
 %%------------------------------------------------------------------------------
 %% helpers
 %%------------------------------------------------------------------------------

+ 5 - 0
changes/ce/breaking-13526.en.md

@@ -0,0 +1,5 @@
+- Core-replicant feature has been removed from the Open-Source Edition.
+  Starting from release 5.8, all nodes running Open-Source Edition will assume Core role.
+  This change doesn't affect Enterprise Edition users.
+
+- Obsolete and unused `cluster.core_nodes` configuration parameter has been removed.