fix(emqx_bridge): don't crash uninstallling broken action
This commit is contained in:
parent
4fe1d332b3
commit
0d33284672
|
@ -360,28 +360,6 @@ uninstall_bridge_v2(
|
|||
%% Already not installed
|
||||
ok;
|
||||
uninstall_bridge_v2(
|
||||
BridgeV2Type,
|
||||
BridgeName,
|
||||
Config
|
||||
) ->
|
||||
uninstall_bridge_v2_helper(
|
||||
BridgeV2Type,
|
||||
BridgeName,
|
||||
combine_connector_and_bridge_v2_config(
|
||||
BridgeV2Type,
|
||||
BridgeName,
|
||||
Config
|
||||
)
|
||||
).
|
||||
|
||||
uninstall_bridge_v2_helper(
|
||||
_BridgeV2Type,
|
||||
_BridgeName,
|
||||
{error, Reason} = Error
|
||||
) ->
|
||||
?SLOG(error, Reason),
|
||||
Error;
|
||||
uninstall_bridge_v2_helper(
|
||||
BridgeV2Type,
|
||||
BridgeName,
|
||||
#{connector := ConnectorName} = Config
|
||||
|
@ -390,11 +368,16 @@ uninstall_bridge_v2_helper(
|
|||
CreationOpts = emqx_resource:fetch_creation_opts(Config),
|
||||
ok = emqx_resource_buffer_worker_sup:stop_workers(BridgeV2Id, CreationOpts),
|
||||
ok = emqx_resource:clear_metrics(BridgeV2Id),
|
||||
%% Deinstall from connector
|
||||
ConnectorId = emqx_connector_resource:resource_id(
|
||||
connector_type(BridgeV2Type), ConnectorName
|
||||
),
|
||||
emqx_resource_manager:remove_channel(ConnectorId, BridgeV2Id).
|
||||
case combine_connector_and_bridge_v2_config(BridgeV2Type, BridgeName, Config) of
|
||||
{error, _} ->
|
||||
ok;
|
||||
_CombinedConfig ->
|
||||
%% Deinstall from connector
|
||||
ConnectorId = emqx_connector_resource:resource_id(
|
||||
connector_type(BridgeV2Type), ConnectorName
|
||||
),
|
||||
emqx_resource_manager:remove_channel(ConnectorId, BridgeV2Id)
|
||||
end.
|
||||
|
||||
combine_connector_and_bridge_v2_config(
|
||||
BridgeV2Type,
|
||||
|
|
Loading…
Reference in New Issue