Просмотр исходного кода

Merge pull request #10043 from zmstone/0228-fix-ssl-dist-optfile

0228 fix ssl dist optfile
Zaiming (Stone) Shi 3 лет назад
Родитель
Сommit
a64f712353
4 измененных файлов с 13 добавлено и 7 удалено
  1. 3 3
      bin/emqx
  2. 3 0
      changes/ce/fix-10043.en.md
  3. 3 0
      changes/ce/fix-10043.zh.md
  4. 4 4
      scripts/test/start-two-nodes-in-docker.sh

+ 3 - 3
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'
@@ -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"

+ 3 - 0
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 overridden from environment variable, EMQX node is unable to start.

+ 3 - 0
changes/ce/fix-10043.zh.md

@@ -0,0 +1,3 @@
+修复 v5.0.18 引入的 2 个bug。
+* 环境变量 `SSL_DIST_OPTFILE` 的值设置错误导致节点无法为 Erlang distribution 启用 SSL。
+* 当节点的 cookie 从环境变量重载 (而不是设置在配置文件中时),节点无法启动的问题。

+ 4 - 4
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"