Przeglądaj źródła

fix(mysql_bridge): make nxdomain a 400 API error

Fixes https://emqx.atlassian.net/browse/EMQX-10460
Thales Macedo Garitezi 2 lat temu
rodzic
commit
c216dfd96b

+ 7 - 3
apps/emqx_bridge/src/emqx_bridge_api.erl

@@ -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, #{

+ 1 - 1
apps/emqx_mysql/rebar.config

@@ -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"}}
 ]}.

+ 1 - 0
changes/ee/fix-11175.en.md

@@ -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.