fix: remove nonexistent listener should always return ok
This commit is contained in:
parent
c6271de174
commit
634a75341a
|
@ -381,7 +381,7 @@ post_config_update([listeners, Type, Name], {update, _Request}, NewConf, OldConf
|
|||
_ -> ok
|
||||
end;
|
||||
post_config_update([listeners, _Type, _Name], '$remove', undefined, undefined, _AppEnvs) ->
|
||||
{error, not_found};
|
||||
ok;
|
||||
post_config_update([listeners, Type, Name], '$remove', undefined, OldConf, _AppEnvs) ->
|
||||
case stop_listener(Type, Name, OldConf) of
|
||||
ok ->
|
||||
|
|
|
@ -355,9 +355,8 @@ crud_listeners_by_id(post, #{bindings := #{id := Id}, body := Body0}) ->
|
|||
end;
|
||||
crud_listeners_by_id(delete, #{bindings := #{id := Id}}) ->
|
||||
{ok, #{type := Type, name := Name}} = emqx_listeners:parse_listener_id(Id),
|
||||
case remove([listeners, Type, Name]) of
|
||||
case ensure_remove([listeners, Type, Name]) of
|
||||
{ok, _} -> {204};
|
||||
{error, not_found} -> {204};
|
||||
{error, Reason} -> {400, #{code => 'BAD_REQUEST', message => err_msg(Reason)}}
|
||||
end.
|
||||
|
||||
|
@ -552,7 +551,7 @@ action(Path, Action, Conf) ->
|
|||
create(Path, Conf) ->
|
||||
wrap(emqx_conf:update(Path, {create, Conf}, ?OPTS(cluster))).
|
||||
|
||||
remove(Path) ->
|
||||
ensure_remove(Path) ->
|
||||
wrap(emqx_conf:remove(Path, ?OPTS(cluster))).
|
||||
|
||||
wrap({error, {post_config_update, emqx_listeners, Reason}}) -> {error, Reason};
|
||||
|
|
|
@ -166,6 +166,11 @@ crud_listeners_by_id(ListenerId, NewListenerId, MinListenerId, BadId, Type) ->
|
|||
?assertEqual([], delete(NewPath)),
|
||||
ok.
|
||||
|
||||
t_delete_nonexistent_listener(_) ->
|
||||
NonExist = emqx_mgmt_api_test_util:api_path(["listeners", "tcp:nonexistent"]),
|
||||
?assertEqual([], delete(NonExist)),
|
||||
ok.
|
||||
|
||||
t_action_listeners(_) ->
|
||||
ID = "tcp:default",
|
||||
action_listener(ID, "stop", false),
|
||||
|
|
Loading…
Reference in New Issue