From a88c42cf82db1851c361c3e73aa1415e498e9b7c Mon Sep 17 00:00:00 2001 From: William Yang Date: Thu, 4 Aug 2022 14:54:39 +0200 Subject: [PATCH] fix(upgrade): ensure use correct no_dot_erlang.boot --- .ci/build_packages/tests.sh | 11 +++++++++++ bin/install_upgrade.escript | 10 ++++++++++ 2 files changed, 21 insertions(+) diff --git a/.ci/build_packages/tests.sh b/.ci/build_packages/tests.sh index b74d61ff2..d4620e2d3 100755 --- a/.ci/build_packages/tests.sh +++ b/.ci/build_packages/tests.sh @@ -144,17 +144,28 @@ relup_test(){ ./emqx/bin/emqx start || ( tail emqx/log/emqx.log.1 && exit 1 ) ./emqx/bin/emqx_ctl status ./emqx/bin/emqx versions + OldVsn="$(./emqx/bin/emqx eval 'Versions=[{S, V} || {_,V,_, S} <- release_handler:which_releases()], + Current = proplists:get_value(current, Versions, proplists:get_value(permanent, Versions)), + io:format("~s", [Current])')" cp "${PACKAGE_PATH}/${EMQX_NAME}"-*-"${TARGET_VERSION}-${ARCH}".zip ./emqx/releases ./emqx/bin/emqx install "${TARGET_VERSION}" [ "$(./emqx/bin/emqx versions |grep permanent | awk '{print $2}')" = "${TARGET_VERSION}" ] || exit 1 export EMQX_WAIT_FOR_STOP=300 ./emqx/bin/emqx_ctl status + + # also test remove old rel + ./emqx/bin/emqx uninstall "$OldVsn" + + # check emqx still runs + ./emqx/bin/emqx ping + if ! ./emqx/bin/emqx stop; then cat emqx/log/erlang.log.1 || true cat emqx/log/emqx.log.1 || true echo "failed to stop emqx" exit 1 fi + rm -rf emqx done fi diff --git a/bin/install_upgrade.escript b/bin/install_upgrade.escript index 14d90156c..88268d893 100755 --- a/bin/install_upgrade.escript +++ b/bin/install_upgrade.escript @@ -111,6 +111,7 @@ uninstall({_RelName, NameTypeArg, NodeName, Cookie}, Opts) -> TargetNode = start_distribution(NodeName, NameTypeArg, Cookie), WhichReleases = which_releases(TargetNode), Version = proplists:get_value(version, Opts), + ensure_latest_boot_file(current_release_version(TargetNode)), case proplists:get_value(Version, WhichReleases) of undefined -> ?INFO("Release ~s is already uninstalled.", [Version]); @@ -362,6 +363,9 @@ permafy(TargetNode, RelName, Vsn) -> [{ok, _} = file:copy(filename:join(["bin", File++"-"++Vsn]), filename:join(["bin", File])) || File <- Scripts], + + ensure_latest_boot_file(Vsn), + %% update the vars UpdatedVars = io_lib:format("REL_VSN=\"~s\"~nERTS_VSN=\"~s\"~n", [Vsn, erts_vsn()]), file:write_file(filename:absname(filename:join(["releases", "emqx_vars"])), UpdatedVars, [append]). @@ -458,3 +462,9 @@ str(A) when is_binary(A) -> binary_to_list(A); str(A) when is_list(A) -> (A). + +%%% For otp upgrade, the boot file need match the otp version +%%% This is for emqx cli tool +ensure_latest_boot_file(Vsn) -> + {ok, _} = file:copy(filename:join(["releases", Vsn, "no_dot_erlang.boot"]), + filename:join(["bin", "no_dot_erlang.boot"])).