Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(emqx_mgmt): call emqx_alarm:delete_all_deactivated_alarms for rem… #9280

Merged
merged 2 commits into from Nov 4, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions apps/emqx_management/src/emqx_mgmt.erl
Expand Up @@ -499,7 +499,7 @@ delete_all_deactivated_alarms() ->
delete_all_deactivated_alarms(Node) when Node =:= node() ->
emqx_alarm:delete_all_deactivated_alarms();
delete_all_deactivated_alarms(Node) ->
rpc_call(Node, delete_deactivated_alarms, [Node]).
rpc_call(Node, emqx_alarm, delete_all_deactivated_alarms, []).

add_duration_field(Alarms) ->
Now = erlang:system_time(microsecond),
Expand Down Expand Up @@ -574,7 +574,10 @@ item(route, {Topic, Node}) ->
%%--------------------------------------------------------------------

rpc_call(Node, Fun, Args) ->
case rpc:call(Node, ?MODULE, Fun, Args) of
rpc_call(Node, ?MODULE, Fun, Args).

rpc_call(Node, Mod, Fun, Args) ->
case rpc:call(Node, Mod, Fun, Args) of
{badrpc, Reason} -> {error, Reason};
Res -> Res
end.
Expand Down
31 changes: 30 additions & 1 deletion apps/emqx_management/test/emqx_mgmt_SUITE.erl
Expand Up @@ -34,7 +34,8 @@ all() ->

groups() ->
[{manage_apps, [sequence],
[t_app
[t_app,
t_alarms
]},
{check_cli, [sequence],
[t_cli,
Expand Down Expand Up @@ -64,6 +65,24 @@ init_per_suite(Config) ->
end_per_suite(_Config) ->
emqx_ct_helpers:stop_apps(apps()).

init_per_testcase(Case, Config) when Case =:= t_alarms ->
try
?MODULE:Case({'init', Config})
catch
error : function_clause ->
Config
end;
init_per_testcase(_, Config) -> Config.

end_per_testcase(Case, Config) when Case =:= t_alarms ->
try
?MODULE:Case({'end', Config})
catch
error : function_clause ->
ok
end;
end_per_testcase(_, Config) -> Config.

t_app(_Config) ->
{ok, AppSecret} = emqx_mgmt_auth:add_app(<<"app_id">>, <<"app_name">>),
?assert(emqx_mgmt_auth:is_authorized(<<"app_id">>, AppSecret)),
Expand Down Expand Up @@ -95,6 +114,16 @@ t_app(_Config) ->
emqx_mgmt_auth:del_app(<<"app_id">>),
ok.

t_alarms({'init', Config}) ->
meck:new(rpc, [unstick]),
meck:expect(rpc, call, 4, ok),
Config;
t_alarms({'end', _}) ->
meck:unload(rpc);
t_alarms(_) ->
ok = emqx_mgmt:delete_all_deactivated_alarms(remote_node),
?assert(meck:called(rpc, call, [remote_node, emqx_alarm, delete_all_deactivated_alarms, []])).

t_log_cmd(_) ->
mock_print(),
lists:foreach(fun(Level) ->
Expand Down
4 changes: 4 additions & 0 deletions changes/v4.3.22-en.md
Expand Up @@ -70,4 +70,8 @@
Note that the `id` in `POST /api/v4/rules` should be literals (not encoded) when creating a `rule` or `resource`.
See docs [Create Rule](https://www.emqx.io/docs/zh/v4.3/advanced/http-api.html#post-api-v4-rules) [Create Resource](https://www.emqx.io/docs/zh/v4.3/advanced/http-api.html#post-api-v4-resources).


- Calling 'DELETE /alarms/deactivated' now deletes deactived alarms on all nodes, including remote nodes, not just the local node [#9280](https://github.com/emqx/emqx/pull/9280).

- When republishing messages or bridge messages to other brokers, check the validity of the topic and make sure it does not have topic wildcards [#9291](https://github.com/emqx/emqx/pull/9291).

4 changes: 4 additions & 0 deletions changes/v4.3.22-zh.md
Expand Up @@ -64,4 +64,8 @@
注意在创建规则或资源时,HTTP body 中的 `id` 字段仍为字面值,而不是编码之后的值。
详情请参考 [创建规则](https://www.emqx.io/docs/zh/v4.3/advanced/http-api.html#post-api-v4-rules) 和 [创建资源](https://www.emqx.io/docs/zh/v4.3/advanced/http-api.html#post-api-v4-resources)。


- 修复调用 'DELETE /alarms/deactivated' 只在单个节点上生效的问题,现在将会删除所有节点上的非活跃警告 [#9280](https://github.com/emqx/emqx/pull/9280)。

- 在进行消息重发布或桥接消息到其他 mqtt broker 时,检查 topic 合法性,确定其不带有主题通配符 [#9291](https://github.com/emqx/emqx/pull/9291)。