fix(rule_engine): update status to false when refresh resource failed (#4821)
* fix(rule_engine): update status to false when refresh resource failed * fix(dialyzer): ignore import_modules/1 created fun has no local return * fix(appup): update appup for rule engine
This commit is contained in:
parent
18036fdf3b
commit
4cd056cab5
|
@ -503,6 +503,7 @@ do_import_acl_mnesia(Acls) ->
|
|||
end.
|
||||
|
||||
-ifdef(EMQX_ENTERPRISE).
|
||||
-dialyzer({nowarn_function, [import_modules/1]}).
|
||||
import_modules(Modules) ->
|
||||
case ets:info(emqx_modules) of
|
||||
undefined ->
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{application, emqx_rule_engine,
|
||||
[{description, "EMQ X Rule Engine"},
|
||||
{vsn, "4.3.1"}, % strict semver, bump manually!
|
||||
{vsn, "4.3.2"}, % strict semver, bump manually!
|
||||
{modules, []},
|
||||
{registered, [emqx_rule_engine_sup, emqx_rule_registry]},
|
||||
{applications, [kernel,stdlib,rulesql,getopt]},
|
||||
|
|
|
@ -1,13 +1,21 @@
|
|||
%% -*-: erlang -*-
|
||||
{"4.3.1",
|
||||
{"4.3.2",
|
||||
[ {"4.3.0",
|
||||
[ {load_module, emqx_rule_funcs, brutal_purge, soft_purge, []}
|
||||
[ {load_module, emqx_rule_funcs, brutal_purge, soft_purge, []},
|
||||
{load_module, emqx_rule_engine, brutal_purge, soft_purge, []}
|
||||
]},
|
||||
{"4.3.1",
|
||||
[ {load_module, emqx_rule_engine, brutal_purge, soft_purge, []}
|
||||
]},
|
||||
{<<".*">>, []}
|
||||
],
|
||||
[
|
||||
{"4.3.0",
|
||||
[ {load_module, emqx_rule_funcs, brutal_purge, soft_purge, []}
|
||||
[ {load_module, emqx_rule_funcs, brutal_purge, soft_purge, []},
|
||||
{load_module, emqx_rule_engine, brutal_purge, soft_purge, []}
|
||||
]},
|
||||
{"4.3.1",
|
||||
[ {load_module, emqx_rule_engine, brutal_purge, soft_purge, []}
|
||||
]},
|
||||
{<<".*">>, []}
|
||||
]
|
||||
|
|
|
@ -408,7 +408,7 @@ refresh_resource_status() ->
|
|||
fun(#resource{id = ResId, type = ResType}) ->
|
||||
case emqx_rule_registry:find_resource_type(ResType) of
|
||||
{ok, #resource_type{on_status = {Mod, OnStatus}}} ->
|
||||
fetch_resource_status(Mod, OnStatus, ResId);
|
||||
_ = fetch_resource_status(Mod, OnStatus, ResId);
|
||||
_ -> ok
|
||||
end
|
||||
end, emqx_rule_registry:get_resources()).
|
||||
|
@ -588,8 +588,7 @@ clear_action(Module, Destroy, ActionInstId) ->
|
|||
fetch_resource_status(Module, OnStatus, ResId) ->
|
||||
case emqx_rule_registry:find_resource_params(ResId) of
|
||||
{ok, ResParams = #resource_params{params = Params, status = #{is_alive := LastIsAlive}}} ->
|
||||
try
|
||||
NewStatus =
|
||||
NewStatus = try
|
||||
case Module:OnStatus(ResId, Params) of
|
||||
#{is_alive := LastIsAlive} = Status -> Status;
|
||||
#{is_alive := true} = Status ->
|
||||
|
@ -602,13 +601,13 @@ fetch_resource_status(Module, OnStatus, ResId) ->
|
|||
Name = alarm_name_of_resource_down(Type, ResId),
|
||||
emqx_alarm:activate(Name, #{id => ResId, type => Type}),
|
||||
Status
|
||||
end,
|
||||
emqx_rule_registry:add_resource_params(ResParams#resource_params{status = NewStatus}),
|
||||
NewStatus
|
||||
end
|
||||
catch _Error:Reason:STrace ->
|
||||
?LOG(error, "get resource status for ~p failed: ~0p", [ResId, {Reason, STrace}]),
|
||||
#{is_alive => false}
|
||||
end;
|
||||
end,
|
||||
emqx_rule_registry:add_resource_params(ResParams#resource_params{status = NewStatus}),
|
||||
NewStatus;
|
||||
not_found ->
|
||||
#{is_alive => false}
|
||||
end.
|
||||
|
|
Loading…
Reference in New Issue