fix: do not leak action configurations in alarm messages

This commit is contained in:
Kjell Winblad 2024-05-22 17:43:07 +02:00
parent cff8b97e8a
commit 4b540e3bd0
1 changed files with 12 additions and 3 deletions

View File

@ -1431,9 +1431,13 @@ maybe_alarm(_Status, _ResId, Error, Error) ->
maybe_alarm(_Status, ResId, Error, _PrevError) ->
HrError =
case Error of
{error, undefined} -> <<"Unknown reason">>;
{error, Reason} -> emqx_utils:readable_error_msg(Reason);
_ -> emqx_utils:readable_error_msg(Error)
{error, undefined} ->
<<"Unknown reason">>;
{error, Reason} ->
emqx_utils:readable_error_msg(Reason);
_ ->
Error1 = redact_config_from_error_status(Error),
emqx_utils:readable_error_msg(Error1)
end,
emqx_alarm:safe_activate(
ResId,
@ -1442,6 +1446,11 @@ maybe_alarm(_Status, ResId, Error, _PrevError) ->
),
?tp(resource_activate_alarm, #{resource_id => ResId}).
redact_config_from_error_status(#{config := _} = ErrorStatus) ->
maps:remove(config, ErrorStatus);
redact_config_from_error_status(Error) ->
Error.
-spec maybe_resume_resource_workers(resource_id(), resource_status()) -> ok.
maybe_resume_resource_workers(ResId, ?status_connected) ->
lists:foreach(