Merge pull request #8653 from qzhuyan/fix/william/use-otp-matching-boot-file

fix(upgrade): ensure use correct no_dot_erlang.boot
This commit is contained in:
William Yang 2022-08-04 17:09:01 +02:00 committed by GitHub
commit f2a9f1b81e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View File

@ -144,17 +144,28 @@ relup_test(){
./emqx/bin/emqx start || ( tail emqx/log/emqx.log.1 && exit 1 ) ./emqx/bin/emqx start || ( tail emqx/log/emqx.log.1 && exit 1 )
./emqx/bin/emqx_ctl status ./emqx/bin/emqx_ctl status
./emqx/bin/emqx versions ./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 cp "${PACKAGE_PATH}/${EMQX_NAME}"-*-"${TARGET_VERSION}-${ARCH}".zip ./emqx/releases
./emqx/bin/emqx install "${TARGET_VERSION}" ./emqx/bin/emqx install "${TARGET_VERSION}"
[ "$(./emqx/bin/emqx versions |grep permanent | awk '{print $2}')" = "${TARGET_VERSION}" ] || exit 1 [ "$(./emqx/bin/emqx versions |grep permanent | awk '{print $2}')" = "${TARGET_VERSION}" ] || exit 1
export EMQX_WAIT_FOR_STOP=300 export EMQX_WAIT_FOR_STOP=300
./emqx/bin/emqx_ctl status ./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 if ! ./emqx/bin/emqx stop; then
cat emqx/log/erlang.log.1 || true cat emqx/log/erlang.log.1 || true
cat emqx/log/emqx.log.1 || true cat emqx/log/emqx.log.1 || true
echo "failed to stop emqx" echo "failed to stop emqx"
exit 1 exit 1
fi fi
rm -rf emqx rm -rf emqx
done done
fi fi

View File

@ -111,6 +111,7 @@ uninstall({_RelName, NameTypeArg, NodeName, Cookie}, Opts) ->
TargetNode = start_distribution(NodeName, NameTypeArg, Cookie), TargetNode = start_distribution(NodeName, NameTypeArg, Cookie),
WhichReleases = which_releases(TargetNode), WhichReleases = which_releases(TargetNode),
Version = proplists:get_value(version, Opts), Version = proplists:get_value(version, Opts),
ensure_latest_boot_file(current_release_version(TargetNode)),
case proplists:get_value(Version, WhichReleases) of case proplists:get_value(Version, WhichReleases) of
undefined -> undefined ->
?INFO("Release ~s is already uninstalled.", [Version]); ?INFO("Release ~s is already uninstalled.", [Version]);
@ -362,6 +363,9 @@ permafy(TargetNode, RelName, Vsn) ->
[{ok, _} = file:copy(filename:join(["bin", File++"-"++Vsn]), [{ok, _} = file:copy(filename:join(["bin", File++"-"++Vsn]),
filename:join(["bin", File])) filename:join(["bin", File]))
|| File <- Scripts], || File <- Scripts],
ensure_latest_boot_file(Vsn),
%% update the vars %% update the vars
UpdatedVars = io_lib:format("REL_VSN=\"~s\"~nERTS_VSN=\"~s\"~n", [Vsn, erts_vsn()]), 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]). 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); binary_to_list(A);
str(A) when is_list(A) -> str(A) when is_list(A) ->
(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"])).