Merge pull request #11256 from thalesmg/bridge-api-ecpool-400-errors-20230712-r51
fix(bridge_api): return 400 for all ecpool start errors
This commit is contained in:
commit
924ed06760
|
@ -983,15 +983,10 @@ call_operation(NodeOrAll, OperFunc, Args = [_Nodes, BridgeType, BridgeName]) ->
|
||||||
%% still on an older bpapi version that doesn't support it.
|
%% still on an older bpapi version that doesn't support it.
|
||||||
maybe_try_restart(NodeOrAll, OperFunc, Args);
|
maybe_try_restart(NodeOrAll, OperFunc, Args);
|
||||||
{error, timeout} ->
|
{error, timeout} ->
|
||||||
?SERVICE_UNAVAILABLE(<<"Request timeout">>);
|
?BAD_REQUEST(<<"Request timeout">>);
|
||||||
{error, {start_pool_failed, Name, Reason}} ->
|
{error, {start_pool_failed, Name, Reason}} ->
|
||||||
Msg = 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);
|
?BAD_REQUEST(Msg);
|
||||||
_ ->
|
|
||||||
?SERVICE_UNAVAILABLE(Msg)
|
|
||||||
end;
|
|
||||||
{error, not_found} ->
|
{error, not_found} ->
|
||||||
BridgeId = emqx_bridge_resource:bridge_id(BridgeType, BridgeName),
|
BridgeId = emqx_bridge_resource:bridge_id(BridgeType, BridgeName),
|
||||||
?SLOG(warning, #{
|
?SLOG(warning, #{
|
||||||
|
|
|
@ -834,7 +834,8 @@ do_start_stop_bridges(Type, Config) ->
|
||||||
),
|
),
|
||||||
BadBridgeID = emqx_bridge_resource:bridge_id(?BRIDGE_TYPE_MQTT, BadName),
|
BadBridgeID = emqx_bridge_resource:bridge_id(?BRIDGE_TYPE_MQTT, BadName),
|
||||||
?assertMatch(
|
?assertMatch(
|
||||||
{ok, SC, _} when SC == 500 orelse SC == 503,
|
%% request from product: return 400 on such errors
|
||||||
|
{ok, SC, _} when SC == 500 orelse SC == 400,
|
||||||
request(post, {operation, Type, start, BadBridgeID}, Config)
|
request(post, {operation, Type, start, BadBridgeID}, Config)
|
||||||
),
|
),
|
||||||
ok = gen_tcp:close(Sock),
|
ok = gen_tcp:close(Sock),
|
||||||
|
|
Loading…
Reference in New Issue