Selaa lähdekoodia

Merge pull request #8872 from JimMoen/fix-mqtt-bridge-fields

Fix mqtt bridge fields.
 - Show ssl file path in Dashboard.
 - MQTT bridge `payload` field not required.
merge `v5.0.7` into `master`.
JimMoen 3 vuotta sitten
vanhempi
commit
d4785553b9

+ 2 - 0
CHANGES-5.0.md

@@ -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
 
@@ -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)

+ 1 - 1
Makefile

@@ -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

+ 1 - 1
apps/emqx/include/emqx_release.hrl

@@ -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").

+ 1 - 1
apps/emqx/src/emqx.app.src

@@ -3,7 +3,7 @@
     {id, "emqx"},
     {description, "EMQX Core"},
     % strict semver, bump manually!
-    {vsn, "5.0.7"},
+    {vsn, "5.0.8"},
     {modules, []},
     {registered, []},
     {applications, [

+ 1 - 1
apps/emqx/src/emqx_schema.erl

@@ -869,7 +869,7 @@ fields("mqtt_quic_listener") ->
             sc(
                 duration_ms(),
                 #{
-                    default => "0",
+                    default => 0,
                     desc => ?DESC(fields_mqtt_quic_listener_idle_timeout)
                 }
             )},

+ 1 - 1
apps/emqx_authn/src/emqx_authn.app.src

@@ -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]},

+ 1 - 1
apps/emqx_bridge/src/emqx_bridge.app.src

@@ -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, [

+ 2 - 1
apps/emqx_bridge/src/emqx_bridge_api.erl

@@ -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),

+ 1 - 1
apps/emqx_connector/src/emqx_connector.app.src

@@ -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, [

+ 76 - 14
apps/emqx_connector/src/emqx_connector_ssl.erl

@@ -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;

+ 1 - 3
apps/emqx_connector/src/mqtt/emqx_connector_mqtt_schema.erl

@@ -87,7 +87,6 @@ fields("connector") ->
             sc(
                 binary(),
                 #{
-                    default => "emqx",
                     desc => ?DESC("username")
                 }
             )},
@@ -95,7 +94,6 @@ fields("connector") ->
             sc(
                 binary(),
                 #{
-                    default => "emqx",
                     desc => ?DESC("password")
                 }
             )},
@@ -226,7 +224,7 @@ fields("egress") ->
             sc(
                 binary(),
                 #{
-                    required => true,
+                    default => <<"${payload}">>,
                     desc => ?DESC("payload")
                 }
             )}

+ 1 - 1
apps/emqx_exhook/src/emqx_exhook.app.src

@@ -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, []}},

+ 1 - 1
apps/emqx_gateway/src/emqx_gateway.app.src

@@ -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]},

+ 1 - 1
apps/emqx_management/src/emqx_management.app.src

@@ -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]},

+ 2 - 2
deploy/charts/emqx/Chart.yaml

@@ -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