From 5427ebc5f1102d8f0e69a401a460c849a4cdd0ee Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Thu, 30 Nov 2023 16:49:30 +0100 Subject: [PATCH] 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 --- apps/emqx_management/src/emqx_mgmt_api_plugins.erl | 5 +++-- apps/emqx_plugins/src/emqx_plugins.erl | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/apps/emqx_management/src/emqx_mgmt_api_plugins.erl b/apps/emqx_management/src/emqx_mgmt_api_plugins.erl index c89ee202e..81a1103d2 100644 --- a/apps/emqx_management/src/emqx_mgmt_api_plugins.erl +++ b/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 -> diff --git a/apps/emqx_plugins/src/emqx_plugins.erl b/apps/emqx_plugins/src/emqx_plugins.erl index 41538daf6..f14a1022a 100644 --- a/apps/emqx_plugins/src/emqx_plugins.erl +++ b/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, _} ->