fix(mysql_bridge): make nxdomain a 400 API error

Fixes https://emqx.atlassian.net/browse/EMQX-10460
This commit is contained in:
Thales Macedo Garitezi 2023-06-30 15:40:40 -03:00
parent 07cf250093
commit c216dfd96b
3 changed files with 9 additions and 4 deletions

View File

@ -985,9 +985,13 @@ call_operation(NodeOrAll, OperFunc, Args = [_Nodes, BridgeType, BridgeName]) ->
{error, timeout} ->
?SERVICE_UNAVAILABLE(<<"Request timeout">>);
{error, {start_pool_failed, Name, Reason}} ->
?SERVICE_UNAVAILABLE(
bin(io_lib:format("Failed to start ~p pool for reason ~p", [Name, Reason]))
);
Msg = bin(io_lib:format("Failed to start ~p pool for reason ~p", [Name, Reason])),
case Reason of
nxdomain ->
?BAD_REQUEST(Msg);
_ ->
?SERVICE_UNAVAILABLE(Msg)
end;
{error, not_found} ->
BridgeId = emqx_bridge_resource:bridge_id(BridgeType, BridgeName),
?SLOG(warning, #{

View File

@ -3,7 +3,7 @@
{erl_opts, [debug_info]}.
{deps, [
%% NOTE: mind ecpool version when updating eredis_cluster version
{mysql, {git, "https://github.com/emqx/mysql-otp", {tag, "1.7.2"}}},
{mysql, {git, "https://github.com/emqx/mysql-otp", {tag, "1.7.3"}}},
{emqx_connector, {path, "../../apps/emqx_connector"}},
{emqx_resource, {path, "../../apps/emqx_resource"}}
]}.

View File

@ -0,0 +1 @@
Now when using a nonexistent hostname for connecting to MySQL will result in a 400 error rather than 503 in the HTTP API.