From e34055b6effe180ceb20ad36fa8380096515d69d Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Mon, 15 Nov 2021 19:24:15 +0100 Subject: [PATCH 1/4] chore: pin OTP-23.2.7.2-emqx-3 --- .tool-versions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.tool-versions b/.tool-versions index 200caa93b..0b6392b95 100644 --- a/.tool-versions +++ b/.tool-versions @@ -1 +1 @@ -erlang 23.2.7.2-emqx-2 +erlang 23.2.7.2-emqx-3 From 4f0d86dd57f305c0e77ca0861da07ddafced37af Mon Sep 17 00:00:00 2001 From: William Yang Date: Tue, 16 Nov 2021 17:48:59 +0100 Subject: [PATCH 2/4] fix(node_dump): locate log dir for package installation --- bin/node_dump | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/bin/node_dump b/bin/node_dump index 056b9a822..859147ac7 100755 --- a/bin/node_dump +++ b/bin/node_dump @@ -1,15 +1,18 @@ #!/bin/sh set -eu +BASE_DIR=$(dirname "$0") ROOT_DIR="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"/..; pwd -P)" +LOG_DIR="$(dirname "$(emqx eval 'hd([ File || #{module := logger_disk_log_h, config := #{file:= File} } <- logger:get_handler_config() ])' | xargs)")" + echo "Running node dump in ${ROOT_DIR}" cd "${ROOT_DIR}" -DUMP="log/node_dump_$(date +"%Y%m%d_%H%M%S").tar.gz" -CONF_DUMP="log/conf.dump" -SYSINFO="log/sysinfo.txt" +DUMP="$LOG_DIR/node_dump_$(date +"%Y%m%d_%H%M%S").tar.gz" +CONF_DUMP="$LOG_DIR/conf.dump" +SYSINFO="$LOG_DIR/sysinfo.txt" LOG_MAX_AGE_DAYS=3 @@ -26,7 +29,7 @@ show_help() { USAGE: - bin/node_dump [-a DAYS] + $0 [-a DAYS] OPTIONS: @@ -44,29 +47,29 @@ done # Collect system info: { - collect bin/emqx_ctl broker - collect bin/emqx eval "'emqx_node_dump:sys_info()'" + collect "$BASE_DIR"/emqx_ctl broker + collect "$BASE_DIR"/emqx eval "'emqx_node_dump:sys_info()'" collect uname -a collect uptime collect free collect netstat -tnl - collect bin/emqx_ctl plugins list - collect bin/emqx_ctl modules list + collect "$BASE_DIR"/emqx_ctl plugins list + collect "$BASE_DIR"/emqx_ctl modules list - collect bin/emqx_ctl vm all - collect bin/emqx_ctl listeners + collect "$BASE_DIR"/emqx_ctl vm all + collect "$BASE_DIR"/emqx_ctl listeners } > "${SYSINFO}" # Collect information about the configuration: { - collect bin/emqx eval "'emqx_node_dump:app_env_dump()'" + collect "$BASE_DIR"/emqx eval "'emqx_node_dump:app_env_dump()'" } > "${CONF_DUMP}" # Pack files { - find log -mtime -"${LOG_MAX_AGE_DAYS}" \( -name '*.log.*' -or -name 'run_erl.log*' \) + find "$LOG_DIR" -mtime -"${LOG_MAX_AGE_DAYS}" \( -name '*.log.*' -or -name 'run_erl.log*' \) echo "${SYSINFO}" echo "${CONF_DUMP}" } | tar czf "${DUMP}" -T - From 59656b3c3a058e2de1a0a62be2abb05538436713 Mon Sep 17 00:00:00 2001 From: William Yang Date: Wed, 17 Nov 2021 11:45:48 +0100 Subject: [PATCH 3/4] fix: source emqx_vars in node_dump tool --- bin/node_dump | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/bin/node_dump b/bin/node_dump index 859147ac7..c8f76841b 100755 --- a/bin/node_dump +++ b/bin/node_dump @@ -1,18 +1,17 @@ #!/bin/sh set -eu -BASE_DIR=$(dirname "$0") ROOT_DIR="$(cd "$(dirname "$(readlink "$0" || echo "$0")")"/..; pwd -P)" -LOG_DIR="$(dirname "$(emqx eval 'hd([ File || #{module := logger_disk_log_h, config := #{file:= File} } <- logger:get_handler_config() ])' | xargs)")" - - echo "Running node dump in ${ROOT_DIR}" +# shellcheck disable=SC1090 +. "$ROOT_DIR"/releases/emqx_vars + cd "${ROOT_DIR}" -DUMP="$LOG_DIR/node_dump_$(date +"%Y%m%d_%H%M%S").tar.gz" -CONF_DUMP="$LOG_DIR/conf.dump" -SYSINFO="$LOG_DIR/sysinfo.txt" +DUMP="$RUNNER_LOG_DIR/node_dump_$(date +"%Y%m%d_%H%M%S").tar.gz" +CONF_DUMP="$RUNNER_LOG_DIR/conf.dump" +SYSINFO="$RUNNER_LOG_DIR/sysinfo.txt" LOG_MAX_AGE_DAYS=3 @@ -47,29 +46,29 @@ done # Collect system info: { - collect "$BASE_DIR"/emqx_ctl broker - collect "$BASE_DIR"/emqx eval "'emqx_node_dump:sys_info()'" + collect "$RUNNER_BIN_DIR"/emqx_ctl broker + collect "$RUNNER_BIN_DIR"/emqx eval "'emqx_node_dump:sys_info()'" collect uname -a collect uptime collect free collect netstat -tnl - collect "$BASE_DIR"/emqx_ctl plugins list - collect "$BASE_DIR"/emqx_ctl modules list + collect "$RUNNER_BIN_DIR"/emqx_ctl plugins list + collect "$RUNNER_BIN_DIR"/emqx_ctl modules list - collect "$BASE_DIR"/emqx_ctl vm all - collect "$BASE_DIR"/emqx_ctl listeners + collect "$RUNNER_BIN_DIR"/emqx_ctl vm all + collect "$RUNNER_BIN_DIR"/emqx_ctl listeners } > "${SYSINFO}" # Collect information about the configuration: { - collect "$BASE_DIR"/emqx eval "'emqx_node_dump:app_env_dump()'" + collect "$RUNNER_BIN_DIR"/emqx eval "'emqx_node_dump:app_env_dump()'" } > "${CONF_DUMP}" # Pack files { - find "$LOG_DIR" -mtime -"${LOG_MAX_AGE_DAYS}" \( -name '*.log.*' -or -name 'run_erl.log*' \) + find "$RUNNER_LOG_DIR" -mtime -"${LOG_MAX_AGE_DAYS}" \( -name '*.log.*' -or -name 'run_erl.log*' \) echo "${SYSINFO}" echo "${CONF_DUMP}" } | tar czf "${DUMP}" -T - From 5db460781507462412c6b7499199aacd48bbcb31 Mon Sep 17 00:00:00 2001 From: Zaiming Shi Date: Wed, 17 Nov 2021 23:22:08 +0100 Subject: [PATCH 4/4] build: ensure symlinks in _build dir are deleted after fetching deps In CI, the source code is downloaded with make deps-all zipped and uploaded as an GitHub action artifact to be downloaded in later steps to build packages The symlinks are abs paths, meaning it might be broken when unziped (inside docker containers) This fix adds a `make clean` step after the deps-all target and the `clean` target also removes rebar.lock and symlinks --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 17ceb9481..49fafe2b0 100644 --- a/Makefile +++ b/Makefile @@ -85,8 +85,10 @@ $(REL_PROFILES:%=%): $(REBAR) get-dashboard clean: $(PROFILES:%=clean-%) $(PROFILES:%=clean-%): @if [ -d _build/$(@:clean-%=%) ]; then \ + rm rebar.lock \ rm -rf _build/$(@:clean-%=%)/rel; \ find _build/$(@:clean-%=%) -name '*.beam' -o -name '*.so' -o -name '*.app' -o -name '*.appup' -o -name '*.o' -o -name '*.d' -type f | xargs rm -f; \ + find _build/$(@:clean-%=%) -type l | xargs rm -i -f ; \ fi .PHONY: clean-all @@ -95,6 +97,7 @@ clean-all: .PHONY: deps-all deps-all: $(REBAR) $(PROFILES:%=deps-%) + @make clean # ensure clean at the end ## deps- is used in CI scripts to download deps and the ## share downloads between CI steps and/or copied into containers @@ -102,6 +105,7 @@ deps-all: $(REBAR) $(PROFILES:%=deps-%) .PHONY: $(PROFILES:%=deps-%) $(PROFILES:%=deps-%): $(REBAR) get-dashboard @$(REBAR) as $(@:deps-%=%) get-deps + @rm -f rebar.lock .PHONY: xref xref: $(REBAR)