Просмотр исходного кода

fix: log error when failed to install plugin

the error return is a map with details.
prior to this change only the reason is returned in the api response,
now the error map is logged at error level to help troubleshooting
Zaiming (Stone) Shi 2 лет назад
Родитель
Сommit
5427ebc5f1

+ 3 - 2
apps/emqx_management/src/emqx_mgmt_api_plugins.erl

@@ -399,7 +399,7 @@ do_install_package(FileName, Bin) ->
                 end,
             {400, #{
                 code => 'BAD_PLUGIN_INFO',
-                message => iolist_to_binary([Reason, ":", FileName])
+                message => iolist_to_binary([Reason, ": ", FileName])
             }}
     end.
 
@@ -445,7 +445,8 @@ install_package(FileName, Bin) ->
     case emqx_plugins:ensure_installed(PackageName) of
         {error, #{return := not_found}} = NotFound ->
             NotFound;
-        {error, _Reason} = Error ->
+        {error, Reason} = Error ->
+            ?SLOG(error, Reason#{msg => "failed_to_install_plugin"}),
             _ = file:delete(File),
             Error;
         Result ->

+ 1 - 1
apps/emqx_plugins/src/emqx_plugins.erl

@@ -83,7 +83,7 @@
 describe(NameVsn) -> read_plugin(NameVsn, #{fill_readme => true}).
 
 %% @doc Install a .tar.gz package placed in install_dir.
--spec ensure_installed(name_vsn()) -> ok | {error, any()}.
+-spec ensure_installed(name_vsn()) -> ok | {error, map()}.
 ensure_installed(NameVsn) ->
     case read_plugin(NameVsn, #{}) of
         {ok, _} ->