fix(rule): restore the metrics for actions in cluster

This commit is contained in:
Shawn 2022-01-14 10:33:32 +08:00
parent 0af912f8a9
commit eec566fe40
1 changed files with 4 additions and 1 deletions

View File

@ -50,6 +50,9 @@
, clear_action/3 , clear_action/3
]). ]).
-export([ restore_action_metrics/2
]).
-type(rule() :: #rule{}). -type(rule() :: #rule{}).
-type(action() :: #action{}). -type(action() :: #action{}).
-type(resource() :: #resource{}). -type(resource() :: #resource{}).
@ -491,7 +494,7 @@ may_update_rule_params(Rule, Params = #{on_action_failed := OnFailed}) ->
may_update_rule_params(Rule = #rule{actions = OldActions}, Params = #{actions := Actions}) -> may_update_rule_params(Rule = #rule{actions = OldActions}, Params = #{actions := Actions}) ->
%% prepare new actions before removing old ones %% prepare new actions before removing old ones
NewActions = prepare_actions(Actions, maps:get(enabled, Params, true)), NewActions = prepare_actions(Actions, maps:get(enabled, Params, true)),
ok = restore_action_metrics(OldActions, NewActions), _ = ?CLUSTER_CALL(restore_action_metrics, [OldActions, NewActions]),
_ = ?CLUSTER_CALL(clear_actions, [OldActions]), _ = ?CLUSTER_CALL(clear_actions, [OldActions]),
may_update_rule_params(Rule#rule{actions = NewActions}, maps:remove(actions, Params)); may_update_rule_params(Rule#rule{actions = NewActions}, maps:remove(actions, Params));
may_update_rule_params(Rule, _Params) -> %% ignore all the unsupported params may_update_rule_params(Rule, _Params) -> %% ignore all the unsupported params