fix: handle resource errors
This commit is contained in:
parent
321fd53132
commit
14da61194e
|
@ -344,6 +344,7 @@ handle_action(RuleId, ActId, Selected, Envs) ->
|
|||
})
|
||||
end.
|
||||
|
||||
-define(IS_RES_DOWN(R), R == stopped; R == not_connected; R == not_found; R == unhealthy_target).
|
||||
do_handle_action(RuleId, {bridge, BridgeType, BridgeName, ResId}, Selected, _Envs) ->
|
||||
?TRACE(
|
||||
"BRIDGE",
|
||||
|
@ -356,6 +357,8 @@ do_handle_action(RuleId, {bridge, BridgeType, BridgeName, ResId}, Selected, _Env
|
|||
of
|
||||
{error, Reason} when Reason == bridge_not_found; Reason == bridge_stopped ->
|
||||
throw(out_of_service);
|
||||
?RESOURCE_ERROR_M(R, _) when ?IS_RES_DOWN(R) ->
|
||||
throw(out_of_service);
|
||||
Result ->
|
||||
Result
|
||||
end;
|
||||
|
@ -520,11 +523,8 @@ inc_action_metrics(RuleId, Result) ->
|
|||
_ = do_inc_action_metrics(RuleId, Result),
|
||||
Result.
|
||||
|
||||
-define(IS_RES_DOWN(R), R == stopped; R == not_connected; R == not_found).
|
||||
do_inc_action_metrics(RuleId, {error, {recoverable_error, _}}) ->
|
||||
emqx_metrics_worker:inc(rule_metrics, RuleId, 'actions.failed.out_of_service');
|
||||
do_inc_action_metrics(RuleId, ?RESOURCE_ERROR_M(R, _)) when ?IS_RES_DOWN(R) ->
|
||||
emqx_metrics_worker:inc(rule_metrics, RuleId, 'actions.failed.out_of_service');
|
||||
do_inc_action_metrics(RuleId, {error, {unrecoverable_error, _}}) ->
|
||||
emqx_metrics_worker:inc(rule_metrics, RuleId, 'actions.failed');
|
||||
do_inc_action_metrics(RuleId, R) ->
|
||||
|
|
Loading…
Reference in New Issue