fix(action/source api): improve returned error message on timeout

This commit is contained in:
Thales Macedo Garitezi 2024-06-04 11:59:00 -03:00
parent 3013189cd7
commit f17aefe3d7
3 changed files with 17 additions and 1 deletions

View File

@ -1151,7 +1151,18 @@ post_config_update([ConfRootKey, BridgeType, BridgeName], _Req, NewConf, undefin
post_config_update([ConfRootKey, BridgeType, BridgeName], _Req, NewConf, OldConf, _AppEnvs) when
ConfRootKey =:= ?ROOT_KEY_ACTIONS; ConfRootKey =:= ?ROOT_KEY_SOURCES
->
ok = uninstall_bridge_v2(ConfRootKey, BridgeType, BridgeName, OldConf),
case uninstall_bridge_v2(ConfRootKey, BridgeType, BridgeName, OldConf) of
ok ->
ok;
{error, timeout} ->
throw(<<
"Timed out trying to remove action or source. Please try again and,"
" if the error persists, try disabling the connector before retrying."
>>);
{error, not_found} ->
%% Should not happen, unless config is inconsistent.
throw(<<"Referenced connector not found">>)
end,
ok = install_bridge_v2(ConfRootKey, BridgeType, BridgeName, NewConf),
Bridges = emqx_utils_maps:deep_put(
[BridgeType, BridgeName], emqx:get_config([ConfRootKey]), NewConf

View File

@ -879,6 +879,8 @@ handle_disable_enable(ConfRootKey, Id, Enable) ->
?SERVICE_UNAVAILABLE(<<"request timeout">>);
{error, timeout} ->
?SERVICE_UNAVAILABLE(<<"request timeout">>);
{error, Reason} when is_binary(Reason) ->
?BAD_REQUEST(Reason);
{error, Reason} ->
?INTERNAL_ERROR(Reason)
end

View File

@ -0,0 +1,3 @@
Now, when attempting to stop a connector, if such operation times out, we forcefully shut down the connector process.
Error messages when attempting to disable an action/source when its underlying connector is stuck were also improved.