fix(emqx_mgmt): call emqx_alarm:delete_all_deactivated_alarms for remote nodes
Old call was calling a non-existant function on current module, instead we make call directly into `emqx_alarm` on remote node.
This commit is contained in:
parent
4614167488
commit
835d3a33ef
|
@ -499,7 +499,7 @@ delete_all_deactivated_alarms() ->
|
||||||
delete_all_deactivated_alarms(Node) when Node =:= node() ->
|
delete_all_deactivated_alarms(Node) when Node =:= node() ->
|
||||||
emqx_alarm:delete_all_deactivated_alarms();
|
emqx_alarm:delete_all_deactivated_alarms();
|
||||||
delete_all_deactivated_alarms(Node) ->
|
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) ->
|
add_duration_field(Alarms) ->
|
||||||
Now = erlang:system_time(microsecond),
|
Now = erlang:system_time(microsecond),
|
||||||
|
@ -574,7 +574,10 @@ item(route, {Topic, Node}) ->
|
||||||
%%--------------------------------------------------------------------
|
%%--------------------------------------------------------------------
|
||||||
|
|
||||||
rpc_call(Node, Fun, Args) ->
|
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};
|
{badrpc, Reason} -> {error, Reason};
|
||||||
Res -> Res
|
Res -> Res
|
||||||
end.
|
end.
|
||||||
|
|
|
@ -34,7 +34,8 @@ all() ->
|
||||||
|
|
||||||
groups() ->
|
groups() ->
|
||||||
[{manage_apps, [sequence],
|
[{manage_apps, [sequence],
|
||||||
[t_app
|
[t_app,
|
||||||
|
t_alarms
|
||||||
]},
|
]},
|
||||||
{check_cli, [sequence],
|
{check_cli, [sequence],
|
||||||
[t_cli,
|
[t_cli,
|
||||||
|
@ -64,6 +65,24 @@ init_per_suite(Config) ->
|
||||||
end_per_suite(_Config) ->
|
end_per_suite(_Config) ->
|
||||||
emqx_ct_helpers:stop_apps(apps()).
|
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) ->
|
t_app(_Config) ->
|
||||||
{ok, AppSecret} = emqx_mgmt_auth:add_app(<<"app_id">>, <<"app_name">>),
|
{ok, AppSecret} = emqx_mgmt_auth:add_app(<<"app_id">>, <<"app_name">>),
|
||||||
?assert(emqx_mgmt_auth:is_authorized(<<"app_id">>, AppSecret)),
|
?assert(emqx_mgmt_auth:is_authorized(<<"app_id">>, AppSecret)),
|
||||||
|
@ -95,6 +114,16 @@ t_app(_Config) ->
|
||||||
emqx_mgmt_auth:del_app(<<"app_id">>),
|
emqx_mgmt_auth:del_app(<<"app_id">>),
|
||||||
ok.
|
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(_) ->
|
t_log_cmd(_) ->
|
||||||
mock_print(),
|
mock_print(),
|
||||||
lists:foreach(fun(Level) ->
|
lists:foreach(fun(Level) ->
|
||||||
|
|
|
@ -41,3 +41,5 @@
|
||||||
- Make sure Rule-Engine API supports Percent-encoding `rule_id` and `resource_id` in HTTP request path [#9190](https://github.com/emqx/emqx/pull/9190).
|
- Make sure Rule-Engine API supports Percent-encoding `rule_id` and `resource_id` in HTTP request path [#9190](https://github.com/emqx/emqx/pull/9190).
|
||||||
Note that the `id` in `POST /api/v4/rules` should be literals (not encoded) when creating a `rule` or `resource`.
|
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).
|
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)
|
||||||
|
|
|
@ -41,3 +41,5 @@
|
||||||
- 使规则引擎 API 在 HTTP 请求路径中支持百分号编码的 `rule_id` 及 `resource_id` [#9190](https://github.com/emqx/emqx/pull/9190)。
|
- 使规则引擎 API 在 HTTP 请求路径中支持百分号编码的 `rule_id` 及 `resource_id` [#9190](https://github.com/emqx/emqx/pull/9190)。
|
||||||
注意在创建规则或资源时,HTTP body 中的 `id` 字段仍为字面值,而不是编码之后的值。
|
注意在创建规则或资源时,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)。
|
详情请参考 [创建规则](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' 只在单个节点上生效的问题,现在将会删除所有节点上的非活跃警告。
|
||||||
|
|
Loading…
Reference in New Issue