fix(machine_boot): inject connector/bridge apps as dependencies to `emqx_connector` app

Fixes https://emqx.atlassian.net/browse/EMQX-11771

For the same reasons as we inject `emqx_bridge_*` applications as dependencies to
`emqx_bridge` when starting the node.  Already configured connectors are started when
`emqx_connector` application starts, and may lead to crashes and noise in the logs.  One
example is to configure a mongodb bridge and restart the node.
This commit is contained in:
Thales Macedo Garitezi 2024-01-19 15:34:14 -03:00
parent e219c3eda1
commit 3207f0ea80
13 changed files with 16 additions and 18 deletions

View File

@ -10,8 +10,7 @@
{applications, [
kernel,
stdlib,
emqx_resource,
emqx_connector
emqx_resource
]},
{env, []},
{licenses, ["Business Source License 1.1"]},

View File

@ -2,7 +2,7 @@
{description, "EMQX HTTP Bridge and Connector Application"},
{vsn, "0.2.2"},
{registered, []},
{applications, [kernel, stdlib, emqx_connector, emqx_resource, ehttpc]},
{applications, [kernel, stdlib, emqx_resource, ehttpc]},
{env, [{emqx_action_info_modules, [emqx_bridge_http_action_info]}]},
{modules, []},
{links, []}

View File

@ -10,9 +10,7 @@
{applications, [
kernel,
stdlib,
emqx_resource,
%% for module emqx_connector_http
emqx_connector
emqx_resource
]},
{env, []},
{licenses, ["Business Source License 1.1"]},

View File

@ -5,7 +5,6 @@
{applications, [
kernel,
stdlib,
emqx_connector,
emqx_resource,
emqx_mongodb
]},

View File

@ -5,7 +5,6 @@
{applications, [
kernel,
stdlib,
emqx_connector,
emqx_resource,
emqx_mysql
]},

View File

@ -5,7 +5,6 @@
{applications, [
kernel,
stdlib,
emqx_connector,
emqx_resource,
emqx_redis
]},

View File

@ -178,6 +178,11 @@ app_deps(App, RebootApps) ->
%% `emqx_bridge' is special in that it needs all the bridges apps to
%% be started before it, so that, when it loads the bridges from
%% configuration, the bridge app and its dependencies need to be up.
%%
%% `emqx_connector' also needs to start all connector dependencies for the same reason.
%% Since standalone apps like `emqx_mongodb' are already dependencies of `emqx_bridge_*'
%% apps, we may apply the same tactic for `emqx_connector' and inject individual bridges
%% as its dependencies.
inject_bridge_deps(RebootAppDeps) ->
BridgeApps = [
App
@ -188,6 +193,8 @@ inject_bridge_deps(RebootAppDeps) ->
fun
({emqx_bridge, Deps0}) when is_list(Deps0) ->
{emqx_bridge, Deps0 ++ BridgeApps};
({emqx_connector, Deps0}) when is_list(Deps0) ->
{emqx_connector, Deps0 ++ BridgeApps};
(App) ->
App
end,

View File

@ -392,7 +392,7 @@ t_create_webhook_v1_bridges_api({'init', Config}) ->
lists:foreach(
fun(App) ->
_ = application:stop(App),
{ok, [App]} = application:ensure_all_started(App)
{ok, _} = application:ensure_all_started(App)
end,
[emqx_connector, emqx_bridge]
),

View File

@ -1,12 +1,11 @@
{application, emqx_mongodb, [
{description, "EMQX MongoDB Connector"},
{vsn, "0.1.4"},
{vsn, "0.1.5"},
{registered, []},
{applications, [
kernel,
stdlib,
mongodb,
emqx_connector,
emqx_resource
]},
{env, []},

View File

@ -1,12 +1,11 @@
{application, emqx_mysql, [
{description, "EMQX MySQL Database Connector"},
{vsn, "0.1.6"},
{vsn, "0.1.7"},
{registered, []},
{applications, [
kernel,
stdlib,
mysql,
emqx_connector,
emqx_resource
]},
{env, []},

View File

@ -1,12 +1,11 @@
{application, emqx_postgresql, [
{description, "EMQX PostgreSQL Database Connector"},
{vsn, "0.1.1"},
{vsn, "0.1.2"},
{registered, []},
{applications, [
kernel,
stdlib,
epgsql,
emqx_connector,
emqx_resource
]},
{env, []},

View File

@ -1,13 +1,12 @@
{application, emqx_redis, [
{description, "EMQX Redis Database Connector"},
{vsn, "0.1.4"},
{vsn, "0.1.5"},
{registered, []},
{applications, [
kernel,
stdlib,
eredis,
eredis_cluster,
emqx_connector,
emqx_resource
]},
{env, []},

View File

@ -0,0 +1 @@
Fixed an issue that could lead to error logs when restarting a node configured with some types of data bridges. Said bridges could also start in a failed state, requiring manual restart.