From f6cb5b607cbf21317bbfa3dcb2fb0fdd15be9154 Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Tue, 28 Feb 2023 20:16:32 +0100 Subject: [PATCH 1/5] fix(bin/emqx): do not check cookie when it's a boot command --- bin/emqx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/emqx b/bin/emqx index f0366c09d..7967a1540 100755 --- a/bin/emqx +++ b/bin/emqx @@ -945,7 +945,7 @@ if [ -n "${EMQX_NODE_COOKIE:-}" ]; then fi COOKIE="${EMQX_NODE__COOKIE:-}" COOKIE_IN_USE="$(get_boot_config 'node.cookie')" -if [ -n "$COOKIE_IN_USE" ] && [ -n "$COOKIE" ] && [ "$COOKIE" != "$COOKIE_IN_USE" ]; then +if [ "$IS_BOOT_COMMAND" != 'yes' ] && [ -n "$COOKIE_IN_USE" ] && [ -n "$COOKIE" ] && [ "$COOKIE" != "$COOKIE_IN_USE" ]; then die "EMQX_NODE__COOKIE is different from the cookie used by $NAME" fi [ -z "$COOKIE" ] && COOKIE="$COOKIE_IN_USE" From f48d054986ff1e2a3944a829ef78c65610f5ccab Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Tue, 28 Feb 2023 20:47:05 +0100 Subject: [PATCH 2/5] fix(bin/emqx): ensure SSL_DIST_OPTFILE is set for non-boot command --- bin/emqx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/emqx b/bin/emqx index 7967a1540..b2bdded86 100755 --- a/bin/emqx +++ b/bin/emqx @@ -525,11 +525,11 @@ else ## only one emqx node is running, get running args from 'ps -ef' output tmp_nodename=$(echo -e "$PS_LINE" | $GREP -oE "\s\-s?name.*" | awk '{print $2}' || true) tmp_cookie=$(echo -e "$PS_LINE" | $GREP -oE "\s\-setcookie.*" | awk '{print $2}' || true) - tmp_dist="$(echo -e "$PS_LINE" | $GREP -oE '\-ssl_dist_optfile\s.+\s' | awk '{print $2}' || true)" + SSL_DIST_OPTFILE="$(echo -e "$PS_LINE" | $GREP -oE '\-ssl_dist_optfile\s.+\s' | awk '{print $2}' || true)" tmp_ticktime="$(echo -e "$PS_LINE" | $GREP -oE '\s\-kernel\snet_ticktime\s.+\s' | awk '{print $3}' || true)" # data_dir is actually not needed, but kept anyway tmp_datadir="$(echo -e "$PS_LINE" | $GREP -oE "\-emqx_data_dir.*" | sed -E 's#.+emqx_data_dir[[:blank:]]##g' | sed -E 's#[[:blank:]]--$##g' || true)" - if [ -z "$tmp_dist" ]; then + if [ -z "$SSL_DIST_OPTFILE" ]; then tmp_proto='inet_tcp' else tmp_proto='inet_tls' From 8d00c003a986dc4f74ec9302392eda979f33da7f Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Tue, 28 Feb 2023 21:06:17 +0100 Subject: [PATCH 3/5] test: fix test script --- scripts/test/start-two-nodes-in-docker.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/test/start-two-nodes-in-docker.sh b/scripts/test/start-two-nodes-in-docker.sh index 720eff0ca..c174bc630 100755 --- a/scripts/test/start-two-nodes-in-docker.sh +++ b/scripts/test/start-two-nodes-in-docker.sh @@ -8,7 +8,7 @@ set -euo pipefail ## this is why a docker network is created, and the containers's names have a dot. # ensure dir -cd -P -- "$(dirname -- "$0")/.." +cd -P -- "$(dirname -- "$0")/../../" IMAGE1="${1}" IMAGE2="${2:-${IMAGE1}}" @@ -94,7 +94,7 @@ backend emqx_dashboard_back # Must use a consistent dispatch when EMQX is running on different versions # because the js files for the dashboard is chunked, having the backends sharing # load randomly will cause the browser fail to GET some chunks (or get bad chunks if names clash) - balance first + balance source mode http server emqx-1 $NODE1:18083 server emqx-2 $NODE2:18083 @@ -146,7 +146,7 @@ wait_for_emqx() { container="$1" wait_limit="$2" wait_sec=0 - while ! docker exec "$container" emqx_ctl status >/dev/null 2>&1; do + while ! docker exec "$container" emqx ctl status; do wait_sec=$(( wait_sec + 1 )) if [ $wait_sec -gt "$wait_limit" ]; then echo "timeout wait for EMQX" @@ -182,4 +182,4 @@ wait_for_haproxy 10 echo -docker exec $NODE1 emqx_ctl cluster join "emqx@$NODE2" +docker exec $NODE1 emqx ctl cluster join "emqx@$NODE2" From 4bc63a6103265cf93918f12096062da88f7feac4 Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Tue, 28 Feb 2023 21:17:07 +0100 Subject: [PATCH 4/5] docs: add changelogs --- changes/ce/fix-10043.en.md | 3 +++ changes/ce/fix-10043.zh.md | 3 +++ 2 files changed, 6 insertions(+) create mode 100644 changes/ce/fix-10043.en.md create mode 100644 changes/ce/fix-10043.zh.md diff --git a/changes/ce/fix-10043.en.md b/changes/ce/fix-10043.en.md new file mode 100644 index 000000000..ae4bd6625 --- /dev/null +++ b/changes/ce/fix-10043.en.md @@ -0,0 +1,3 @@ +Fixed two bugs introduced in v5.0.18. +* The environment varialbe `SSL_DIST_OPTFILE` was not set correctly for non-boot commands. +* When cookie is overriden from environment variable, EMQX node is unable to start. diff --git a/changes/ce/fix-10043.zh.md b/changes/ce/fix-10043.zh.md new file mode 100644 index 000000000..6b150f6fb --- /dev/null +++ b/changes/ce/fix-10043.zh.md @@ -0,0 +1,3 @@ +修复 v5.0.18 引入的 2 个bug。 +* 环境变量 `SSL_DIST_OPTFILE` 的值设置错误导致节点无法为 Erlang distribution 启用 SSL。 +* 当节点的 cookie 从环境变量重载 (而不是设置在配置文件中时),节点无法启动的问题。 From a8d48bf571bdb6e059ab0266b8f155e764f51c08 Mon Sep 17 00:00:00 2001 From: "Zaiming (Stone) Shi" Date: Tue, 28 Feb 2023 21:42:06 +0100 Subject: [PATCH 5/5] docs: Update changes/ce/fix-10043.en.md Co-authored-by: Thales Macedo Garitezi --- changes/ce/fix-10043.en.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changes/ce/fix-10043.en.md b/changes/ce/fix-10043.en.md index ae4bd6625..4fd46cb4e 100644 --- a/changes/ce/fix-10043.en.md +++ b/changes/ce/fix-10043.en.md @@ -1,3 +1,3 @@ Fixed two bugs introduced in v5.0.18. * The environment varialbe `SSL_DIST_OPTFILE` was not set correctly for non-boot commands. -* When cookie is overriden from environment variable, EMQX node is unable to start. +* When cookie is overridden from environment variable, EMQX node is unable to start.