Explorar el Código

fix(api_keys): only load bootstrap file on `core` node

firest hace 1 año
padre
commit
90e4c834dc
Se han modificado 2 ficheros con 10 adiciones y 4 borrados
  1. 9 4
      apps/emqx_management/src/emqx_mgmt_auth.erl
  2. 1 0
      changes/ce/fix-14313.en.md

+ 9 - 4
apps/emqx_management/src/emqx_mgmt_auth.erl

@@ -117,10 +117,15 @@ post_config_update([api_key], _Req, NewConf, _OldConf, _AppEnvs) ->
 
 -spec try_init_bootstrap_file() -> ok | {error, _}.
 try_init_bootstrap_file() ->
-    File = bootstrap_file(),
-    ?SLOG(debug, #{msg => "init_bootstrap_api_keys_from_file", file => File}),
-    _ = init_bootstrap_file(File),
-    ok.
+    case mria_rlog:role() of
+        core ->
+            File = bootstrap_file(),
+            ?SLOG(debug, #{msg => "init_bootstrap_api_keys_from_file", file => File}),
+            _ = init_bootstrap_file(File),
+            ok;
+        _ ->
+            ok
+    end.
 
 create(Name, Enable, ExpiredAt, Desc, Role) ->
     ApiKey = generate_unique_api_key(Name),

+ 1 - 0
changes/ce/fix-14313.en.md

@@ -0,0 +1 @@
+Load the bootstrap file for the REST API keys only in the `core` nodes to avoid potential risk of EMQX getting stuck.