Skip to content

Commit

Permalink
Merge pull request #8872 from JimMoen/fix-mqtt-bridge-fields
Browse files Browse the repository at this point in the history
Fix mqtt bridge fields.
 - Show ssl file path in Dashboard.
 - MQTT bridge `payload` field not required.
merge `v5.0.7` into `master`.
  • Loading branch information
JimMoen committed Sep 5, 2022
2 parents 81234e1 + d533e35 commit d478555
Show file tree
Hide file tree
Showing 15 changed files with 93 additions and 30 deletions.
2 changes: 2 additions & 0 deletions CHANGES-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
* Remove `will_msg` (not used) field from the client API. [#8721](https://github.com/emqx/emqx/pull/8721)
* Fix `$queue` topic name error in management API return. [#8728](https://github.com/emqx/emqx/pull/8728)
* Fix race condition which may cause `client.connected` and `client.disconnected` out of order. [#8625](https://github.com/emqx/emqx/pull/8625)
* Fix quic listener default idle timeout's type. [#8826](https://github.com/emqx/emqx/pull/8826)

## Enhancements

Expand All @@ -37,6 +38,7 @@

## Enhancements

* Add `bootstrap_users_file` configuration to add default Dashboard username list, which is only added when EMQX is first started.
* The license is now copied to all nodes in the cluster when it's reloaded. [#8598](https://github.com/emqx/emqx/pull/8598)
* Added a HTTP API to manage licenses. [#8610](https://github.com/emqx/emqx/pull/8610)
* Updated `/nodes` API node_status from `Running/Stopped` to `running/stopped`. [#8642](https://github.com/emqx/emqx/pull/8642)
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export EMQX_DEFAULT_BUILDER = ghcr.io/emqx/emqx-builder/5.0-17:1.13.4-24.2.1-1-d
export EMQX_DEFAULT_RUNNER = debian:11-slim
export OTP_VSN ?= $(shell $(CURDIR)/scripts/get-otp-vsn.sh)
export ELIXIR_VSN ?= $(shell $(CURDIR)/scripts/get-elixir-vsn.sh)
export EMQX_DASHBOARD_VERSION ?= v1.0.7
export EMQX_DASHBOARD_VERSION ?= v1.0.8
export EMQX_EE_DASHBOARD_VERSION ?= e1.0.0
export EMQX_REL_FORM ?= tgz
export QUICER_DOWNLOAD_FROM_RELEASE = 1
Expand Down
2 changes: 1 addition & 1 deletion apps/emqx/include/emqx_release.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
%% `apps/emqx/src/bpapi/README.md'

%% Community edition
-define(EMQX_RELEASE_CE, "5.0.6").
-define(EMQX_RELEASE_CE, "5.0.7").

%% Enterprise edition
-define(EMQX_RELEASE_EE, "5.0.0-alpha.1").
Expand Down
2 changes: 1 addition & 1 deletion apps/emqx/src/emqx.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{id, "emqx"},
{description, "EMQX Core"},
% strict semver, bump manually!
{vsn, "5.0.7"},
{vsn, "5.0.8"},
{modules, []},
{registered, []},
{applications, [
Expand Down
2 changes: 1 addition & 1 deletion apps/emqx/src/emqx_schema.erl
Original file line number Diff line number Diff line change
Expand Up @@ -869,7 +869,7 @@ fields("mqtt_quic_listener") ->
sc(
duration_ms(),
#{
default => "0",
default => 0,
desc => ?DESC(fields_mqtt_quic_listener_idle_timeout)
}
)},
Expand Down
2 changes: 1 addition & 1 deletion apps/emqx_authn/src/emqx_authn.app.src
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_authn, [
{description, "EMQX Authentication"},
{vsn, "0.1.5"},
{vsn, "0.1.6"},
{modules, []},
{registered, [emqx_authn_sup, emqx_authn_registry]},
{applications, [kernel, stdlib, emqx_resource, ehttpc, epgsql, mysql, jose]},
Expand Down
2 changes: 1 addition & 1 deletion apps/emqx_bridge/src/emqx_bridge.app.src
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_bridge, [
{description, "An OTP application"},
{vsn, "0.1.2"},
{vsn, "0.1.3"},
{registered, []},
{mod, {emqx_bridge_app, []}},
{applications, [
Expand Down
3 changes: 2 additions & 1 deletion apps/emqx_bridge/src/emqx_bridge_api.erl
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,10 @@ pick_bridges_by_id(Type, Name, BridgesAllNodes) ->

format_bridge_info([FirstBridge | _] = Bridges) ->
Res = maps:remove(node, FirstBridge),
NRes = emqx_connector_ssl:drop_invalid_certs(Res),
NodeStatus = collect_status(Bridges),
NodeMetrics = collect_metrics(Bridges),
Res#{
NRes#{
status => aggregate_status(NodeStatus),
node_status => NodeStatus,
metrics => aggregate_metrics(NodeMetrics),
Expand Down
2 changes: 1 addition & 1 deletion apps/emqx_connector/src/emqx_connector.app.src
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_connector, [
{description, "An OTP application"},
{vsn, "0.1.4"},
{vsn, "0.1.5"},
{registered, []},
{mod, {emqx_connector_app, []}},
{applications, [
Expand Down
90 changes: 76 additions & 14 deletions apps/emqx_connector/src/emqx_connector_ssl.erl
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,89 @@

-export([
convert_certs/2,
drop_invalid_certs/1,
clear_certs/2
]).

convert_certs(RltvDir, NewConfig) ->
NewSSL = map_get_oneof([<<"ssl">>, ssl], NewConfig, undefined),
case emqx_tls_lib:ensure_ssl_files(RltvDir, NewSSL) of
{ok, NewSSL1} ->
{ok, new_ssl_config(NewConfig, NewSSL1)};
%% TODO: rm `connector` case after `dev/ee5.0` merged into `master`.
%% The `connector` config layer will be removed.
%% for bridges with `connector` field. i.e. `mqtt_source` and `mqtt_sink`
convert_certs(RltvDir, #{<<"connector">> := Connector} = Config) when
is_map(Connector)
->
SSL = map_get_oneof([<<"ssl">>, ssl], Connector, undefined),
new_ssl_config(RltvDir, Config, SSL);
convert_certs(RltvDir, #{connector := Connector} = Config) when
is_map(Connector)
->
SSL = map_get_oneof([<<"ssl">>, ssl], Connector, undefined),
new_ssl_config(RltvDir, Config, SSL);
%% for bridges without `connector` field. i.e. webhook
convert_certs(RltvDir, #{<<"ssl">> := SSL} = Config) ->
new_ssl_config(RltvDir, Config, SSL);
convert_certs(RltvDir, #{ssl := SSL} = Config) ->
new_ssl_config(RltvDir, Config, SSL);
%% for bridges use connector name
convert_certs(_RltvDir, Config) ->
{ok, Config}.

clear_certs(RltvDir, #{<<"connector">> := Connector} = _Config) when
is_map(Connector)
->
OldSSL = map_get_oneof([<<"ssl">>, ssl], Connector, undefined),
ok = emqx_tls_lib:delete_ssl_files(RltvDir, undefined, OldSSL);
clear_certs(RltvDir, #{connector := Connector} = _Config) when
is_map(Connector)
->
OldSSL = map_get_oneof([<<"ssl">>, ssl], Connector, undefined),
ok = emqx_tls_lib:delete_ssl_files(RltvDir, undefined, OldSSL);
clear_certs(RltvDir, #{<<"ssl">> := OldSSL} = _Config) ->
ok = emqx_tls_lib:delete_ssl_files(RltvDir, undefined, OldSSL);
clear_certs(RltvDir, #{ssl := OldSSL} = _Config) ->
ok = emqx_tls_lib:delete_ssl_files(RltvDir, undefined, OldSSL);
clear_certs(_RltvDir, _) ->
ok.

drop_invalid_certs(#{<<"connector">> := Connector} = Config) when
is_map(Connector)
->
SSL = map_get_oneof([<<"ssl">>, ssl], Connector, undefined),
NewSSL = emqx_tls_lib:drop_invalid_certs(SSL),
new_ssl_config(Config, NewSSL);
drop_invalid_certs(#{connector := Connector} = Config) when
is_map(Connector)
->
SSL = map_get_oneof([<<"ssl">>, ssl], Connector, undefined),
NewSSL = emqx_tls_lib:drop_invalid_certs(SSL),
new_ssl_config(Config, NewSSL);
drop_invalid_certs(#{<<"ssl">> := SSL} = Config) ->
NewSSL = emqx_tls_lib:drop_invalid_certs(SSL),
new_ssl_config(Config, NewSSL);
drop_invalid_certs(#{ssl := SSL} = Config) ->
NewSSL = emqx_tls_lib:drop_invalid_certs(SSL),
new_ssl_config(Config, NewSSL);
%% for bridges use connector name
drop_invalid_certs(Config) ->
Config.

new_ssl_config(RltvDir, Config, SSL) ->
case emqx_tls_lib:ensure_ssl_files(RltvDir, SSL) of
{ok, NewSSL} ->
{ok, new_ssl_config(Config, NewSSL)};
{error, Reason} ->
{error, {bad_ssl_config, Reason}}
end.

clear_certs(_RltvDir, undefined) ->
ok;
clear_certs(RltvDir, Config) ->
OldSSL = map_get_oneof([<<"ssl">>, ssl], Config, undefined),
ok = emqx_tls_lib:delete_ssl_files(RltvDir, undefined, OldSSL).

new_ssl_config(Config, undefined) -> Config;
new_ssl_config(Config, #{<<"enable">> := _} = SSL) -> Config#{<<"ssl">> => SSL};
new_ssl_config(Config, #{enable := _} = SSL) -> Config#{ssl => SSL}.
new_ssl_config(#{connector := Connector} = Config, NewSSL) ->
Config#{connector => Connector#{ssl => NewSSL}};
new_ssl_config(#{<<"connector">> := Connector} = Config, NewSSL) ->
Config#{<<"connector">> => Connector#{<<"ssl">> => NewSSL}};
new_ssl_config(#{ssl := _} = Config, NewSSL) ->
Config#{ssl => NewSSL};
new_ssl_config(#{<<"ssl">> := _} = Config, NewSSL) ->
Config#{<<"ssl">> => NewSSL};
new_ssl_config(Config, _NewSSL) ->
Config.

map_get_oneof([], _Map, Default) ->
Default;
Expand Down
4 changes: 1 addition & 3 deletions apps/emqx_connector/src/mqtt/emqx_connector_mqtt_schema.erl
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,13 @@ fields("connector") ->
sc(
binary(),
#{
default => "emqx",
desc => ?DESC("username")
}
)},
{password,
sc(
binary(),
#{
default => "emqx",
desc => ?DESC("password")
}
)},
Expand Down Expand Up @@ -226,7 +224,7 @@ fields("egress") ->
sc(
binary(),
#{
required => true,
default => <<"${payload}">>,
desc => ?DESC("payload")
}
)}
Expand Down
2 changes: 1 addition & 1 deletion apps/emqx_exhook/src/emqx_exhook.app.src
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_exhook, [
{description, "EMQX Extension for Hook"},
{vsn, "5.0.3"},
{vsn, "5.0.4"},
{modules, []},
{registered, []},
{mod, {emqx_exhook_app, []}},
Expand Down
2 changes: 1 addition & 1 deletion apps/emqx_gateway/src/emqx_gateway.app.src
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
%% -*- mode: erlang -*-
{application, emqx_gateway, [
{description, "The Gateway management application"},
{vsn, "0.1.4"},
{vsn, "0.1.5"},
{registered, []},
{mod, {emqx_gateway_app, []}},
{applications, [kernel, stdlib, grpc, emqx, emqx_authn]},
Expand Down
2 changes: 1 addition & 1 deletion apps/emqx_management/src/emqx_management.app.src
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{application, emqx_management, [
{description, "EMQX Management API and CLI"},
% strict semver, bump manually!
{vsn, "5.0.4"},
{vsn, "5.0.5"},
{modules, []},
{registered, [emqx_management_sup]},
{applications, [kernel, stdlib, emqx_plugins, minirest, emqx]},
Expand Down
4 changes: 2 additions & 2 deletions deploy/charts/emqx/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ type: application

# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
version: 5
version: 5.0.7

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application.
appVersion: latest
appVersion: 5.0.7

0 comments on commit d478555

Please sign in to comment.