Merge remote-tracking branch 'origin/release-v43' into main-v4.3

This commit is contained in:
Zaiming (Stone) Shi 2022-11-26 15:59:29 +01:00
commit fdfb735327
7 changed files with 53 additions and 25 deletions

View File

@ -95,6 +95,9 @@
end end
end()). end()).
-define(GET_RES_ALIVE_TIMEOUT, 60000).
-define(PROBE_RES_PREFIX, "__probe__:").
%%------------------------------------------------------------------------------ %%------------------------------------------------------------------------------
%% Load resource/action providers from all available applications %% Load resource/action providers from all available applications
%%------------------------------------------------------------------------------ %%------------------------------------------------------------------------------
@ -363,7 +366,7 @@ test_resource(#{type := Type} = Params) ->
{ok, #resource_type{}} -> {ok, #resource_type{}} ->
%% Resource will be deleted after test. %% Resource will be deleted after test.
%% Use random resource id, ensure test func will not delete the resource in used. %% Use random resource id, ensure test func will not delete the resource in used.
ResId = resource_id(), ResId = probe_resource_id(),
try try
case create_resource(maps:put(id, ResId, Params), no_retry) of case create_resource(maps:put(id, ResId, Params), no_retry) of
{ok, _} -> {ok, _} ->
@ -405,7 +408,7 @@ is_resource_alive(Nodes, ResId, _Opts = #{fetch := true}) ->
{ok, #resource_type{on_status = {Mod, OnStatus}}} {ok, #resource_type{on_status = {Mod, OnStatus}}}
= emqx_rule_registry:find_resource_type(ResType), = emqx_rule_registry:find_resource_type(ResType),
case rpc:multicall(Nodes, case rpc:multicall(Nodes,
?MODULE, fetch_resource_status, [Mod, OnStatus, ResId], 5000) of ?MODULE, fetch_resource_status, [Mod, OnStatus, ResId], ?GET_RES_ALIVE_TIMEOUT) of
{ResL, []} -> {ResL, []} ->
is_resource_alive_(ResL); is_resource_alive_(ResL);
{_, _Error} -> {_, _Error} ->
@ -420,7 +423,7 @@ is_resource_alive(Nodes, ResId, _Opts = #{fetch := true}) ->
end; end;
is_resource_alive(Nodes, ResId, _Opts = #{fetch := false}) -> is_resource_alive(Nodes, ResId, _Opts = #{fetch := false}) ->
try try
case rpc:multicall(Nodes, ?MODULE, get_resource_status, [ResId], 5000) of case rpc:multicall(Nodes, ?MODULE, get_resource_status, [ResId], ?GET_RES_ALIVE_TIMEOUT) of
{ResL, []} -> {ResL, []} ->
is_resource_alive_(ResL); is_resource_alive_(ResL);
{_, _Errors} -> {_, _Errors} ->
@ -532,10 +535,15 @@ refresh_rule(#rule{id = RuleId, for = Topics, actions = Actions}) ->
refresh_resource_status() -> refresh_resource_status() ->
lists:foreach( lists:foreach(
fun(#resource{id = ResId, type = ResType}) -> fun(#resource{id = ResId, type = ResType}) ->
case emqx_rule_registry:find_resource_type(ResType) of case is_prober(ResId) of
{ok, #resource_type{on_status = {Mod, OnStatus}}} -> false ->
fetch_resource_status(Mod, OnStatus, ResId); case emqx_rule_registry:find_resource_type(ResType) of
_ -> ok {ok, #resource_type{on_status = {Mod, OnStatus}}} ->
fetch_resource_status(Mod, OnStatus, ResId);
_ -> ok
end;
true ->
ok
end end
end, emqx_rule_registry:get_resources()). end, emqx_rule_registry:get_resources()).
@ -662,6 +670,9 @@ ignore_lib_apps(Apps) ->
resource_id() -> resource_id() ->
gen_id("resource:", fun emqx_rule_registry:find_resource/1). gen_id("resource:", fun emqx_rule_registry:find_resource/1).
probe_resource_id() ->
gen_id(?PROBE_RES_PREFIX, fun emqx_rule_registry:find_resource/1).
rule_id() -> rule_id() ->
gen_id("rule:", fun emqx_rule_registry:get_rule/1). gen_id("rule:", fun emqx_rule_registry:get_rule/1).
@ -811,4 +822,9 @@ find_type(ResId) ->
{ok, Type}. {ok, Type}.
alarm_name_of_resource_down(Type, ResId) -> alarm_name_of_resource_down(Type, ResId) ->
list_to_binary(io_lib:format("resource/~s/~s/down", [Type, ResId])). unicode:characters_to_binary(io_lib:format("resource/~ts/~ts/down", [Type, ResId])).
is_prober(<<?PROBE_RES_PREFIX, _/binary>>) ->
true;
is_prober(_ResId) ->
false.

View File

@ -62,7 +62,8 @@ groups() ->
t_create_rule, t_create_rule,
t_reset_metrics, t_reset_metrics,
t_reset_metrics_fallbacks, t_reset_metrics_fallbacks,
t_create_resource t_create_resource,
t_clean_resource_alarms
]}, ]},
{actions, [], {actions, [],
[t_inspect_action [t_inspect_action
@ -307,21 +308,29 @@ t_create_resource(_Config) ->
ok. ok.
t_clean_resource_alarms(_Config) -> t_clean_resource_alarms(_Config) ->
lists:foreach(fun(ResId) ->
clean_resource_alarms(ResId)
end, [<<"abc">>, <<"哈喽"/utf8>>]).
clean_resource_alarms(ResId) ->
emqx_rule_registry:register_resource_types(
[make_simple_debug_resource_type()]),
ok = emqx_rule_engine:load_providers(), ok = emqx_rule_engine:load_providers(),
{ok, #resource{id = ResId}} = emqx_rule_engine:create_resource( {ok, #resource{id = ResId}} = emqx_rule_engine:create_resource(
#{type => built_in, #{id => ResId,
type => built_in,
config => #{}, config => #{},
description => <<"debug resource">>}), description => <<"debug resource">>}),
?assert(true, is_binary(ResId)),
Name = emqx_rule_engine:alarm_name_of_resource_down(ResId, built_in), Name = emqx_rule_engine:alarm_name_of_resource_down(ResId, built_in),
_ = emqx_alarm:activate(Name, #{id => ResId, type => built_in}), _ = emqx_alarm:activate(Name, #{id => ResId, type => built_in}),
AlarmExist = fun(#{name := AName}) -> AName == Name end, AlarmExist = fun(#{name := AName}) -> AName == Name end,
Len = length(lists:filter(AlarmExist, emqx_alarm:get_alarms())), Len = length(lists:filter(AlarmExist, emqx_alarm:get_alarms(activated))),
?assert(Len == 1), ?assertEqual(1, Len),
emqx_rule_engine:ensure_resource_deleted(ResId),
emqx_alarm:deactivate(Name),
LenAfterRemove = length(lists:filter(AlarmExist, emqx_alarm:get_alarms(activated))),
?assertEqual(0, LenAfterRemove),
ok = emqx_rule_engine:unload_providers(), ok = emqx_rule_engine:unload_providers(),
emqx_rule_registry:remove_resource(ResId),
LenAfterRemove = length(lists:filter(AlarmExist, emqx_alarm:get_alarms())),
?assert(LenAfterRemove == 0),
ok. ok.
%%------------------------------------------------------------------------------ %%------------------------------------------------------------------------------

View File

@ -1,7 +1,8 @@
# v4.3.22 # v4.3.22
## Enhancements This marks the last release of EMQX v4.3 Opensource Edition.
## Enhancements
- Make sure listener's `tls_versions` config value is one or more of `tlsv1`, `tlsv1.1`, `tlsv1.2`, `tlsv1.3` [#9260](https://github.com/emqx/emqx/pull/9260). - Make sure listener's `tls_versions` config value is one or more of `tlsv1`, `tlsv1.1`, `tlsv1.2`, `tlsv1.3` [#9260](https://github.com/emqx/emqx/pull/9260).

View File

@ -1,5 +1,7 @@
# v4.3.22 # v4.3.22
这是 EMQX 开原版 v4.3 系列的最后一个版本。
## 增强 ## 增强
- 检查监听器的 `tls_versions` 配置值是 `tlsv1``tlsv1.1``tlsv1.2``tlsv1.3` 中的一个或多个组合 [#9260](https://github.com/emqx/emqx/pull/9260)。 - 检查监听器的 `tls_versions` 配置值是 `tlsv1``tlsv1.1``tlsv1.2``tlsv1.3` 中的一个或多个组合 [#9260](https://github.com/emqx/emqx/pull/9260)。

View File

@ -29,7 +29,7 @@
-ifndef(EMQX_ENTERPRISE). -ifndef(EMQX_ENTERPRISE).
-define(EMQX_RELEASE, {opensource, "4.3.22-alpha.1"}). -define(EMQX_RELEASE, {opensource, "4.3.22"}).
-else. -else.

View File

@ -61,7 +61,7 @@
, {getopt, "1.0.1"} , {getopt, "1.0.1"}
, {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "1.0.1"}}} , {snabbkaffe, {git, "https://github.com/kafka4beam/snabbkaffe.git", {tag, "1.0.1"}}}
, {lc, {git, "https://github.com/emqx/lc.git", {tag, "0.3.2"}}} , {lc, {git, "https://github.com/emqx/lc.git", {tag, "0.3.2"}}}
, {mongodb, {git,"https://github.com/emqx/mongodb-erlang", {tag, "v3.0.14"}}} , {mongodb, {git,"https://github.com/emqx/mongodb-erlang", {tag, "v3.0.15"}}}
, {epgsql, {git, "https://github.com/emqx/epgsql.git", {tag, "4.6.0"}}} , {epgsql, {git, "https://github.com/emqx/epgsql.git", {tag, "4.6.0"}}}
, {grpc, {git, "https://github.com/emqx/grpc-erl", {tag, "0.6.7"}}} , {grpc, {git, "https://github.com/emqx/grpc-erl", {tag, "0.6.7"}}}
]}. ]}.

View File

@ -42,11 +42,11 @@ for keychain in ${keychains}; do
done done
security -v list-keychains -s "${keychain_names[@]}" "${KEYCHAIN}" security -v list-keychains -s "${keychain_names[@]}" "${KEYCHAIN}"
# sign # known runtime executables and binaries
codesign -s "${APPLE_DEVELOPER_IDENTITY}" -f --verbose=4 --timestamp --options=runtime "${REL_DIR}"/erts-*/bin/{beam.smp,dyn_erl,epmd,erl,erl_call,erl_child_setup,erlexec,escript,heart,inet_gethost,run_erl,to_erl} codesign -s "${APPLE_DEVELOPER_IDENTITY}" -f --verbose=4 --timestamp --options=runtime "${REL_DIR}"/erts-*/bin/{beam.smp,dyn_erl,epmd,erl,erl_call,erl_child_setup,erlexec,escript,heart,inet_gethost,run_erl,to_erl}
codesign -s "${APPLE_DEVELOPER_IDENTITY}" -f --verbose=4 --timestamp --options=runtime "${REL_DIR}"/lib/asn1-*/priv/lib/asn1rt_nif.so
codesign -s "${APPLE_DEVELOPER_IDENTITY}" -f --verbose=4 --timestamp --options=runtime "${REL_DIR}"/lib/bcrypt-*/priv/bcrypt_nif.so
codesign -s "${APPLE_DEVELOPER_IDENTITY}" -f --verbose=4 --timestamp --options=runtime "${REL_DIR}"/lib/crypto-*/priv/lib/{crypto.so,otp_test_engine.so}
codesign -s "${APPLE_DEVELOPER_IDENTITY}" -f --verbose=4 --timestamp --options=runtime "${REL_DIR}"/lib/jiffy-*/priv/jiffy.so
codesign -s "${APPLE_DEVELOPER_IDENTITY}" -f --verbose=4 --timestamp --options=runtime "${REL_DIR}"/lib/os_mon-*/priv/bin/{cpu_sup,memsup}
codesign -s "${APPLE_DEVELOPER_IDENTITY}" -f --verbose=4 --timestamp --options=runtime "${REL_DIR}"/lib/runtime_tools-*/priv/lib/{dyntrace.so,trace_ip_drv.so,trace_file_drv.so} codesign -s "${APPLE_DEVELOPER_IDENTITY}" -f --verbose=4 --timestamp --options=runtime "${REL_DIR}"/lib/runtime_tools-*/priv/lib/{dyntrace.so,trace_ip_drv.so,trace_file_drv.so}
codesign -s "${APPLE_DEVELOPER_IDENTITY}" -f --verbose=4 --timestamp --options=runtime "${REL_DIR}"/lib/os_mon-*/priv/bin/{cpu_sup,memsup}
# other files from runtime and dependencies
for f in asn1rt_nif.so bcrypt_nif.so crypto.so otp_test_engine.so crypto_callback.so jiffy.so crc32cer_nif.so sasl_auth.so snappyer.so odbcserver; do
find "${REL_DIR}"/lib/ -name "$f" -exec codesign -s "${APPLE_DEVELOPER_IDENTITY}" -f --verbose=4 --timestamp --options=runtime {} \;
done