Merge pull request #7121 from terry-xiaoyu/fix_rel_upgrade_failed_on_eexists
fix(relup): release upgrade failed on symlink already exists
This commit is contained in:
commit
75b322cc2a
|
@ -18,8 +18,9 @@
|
||||||
?>
|
?>
|
||||||
|
|
||||||
[shell emqx]
|
[shell emqx]
|
||||||
|
!OLD_VSN=$(echo $OLD_VSN | sed -r 's/[v|e]//g')
|
||||||
!cd $PACKAGE_PATH
|
!cd $PACKAGE_PATH
|
||||||
!unzip -q -o $PROFILE-ubuntu20.04-$(echo $OLD_VSN | sed -r 's/[v|e]//g')-amd64.zip
|
!unzip -q -o $PROFILE-ubuntu20.04-$${OLD_VSN}-amd64.zip
|
||||||
?SH-PROMPT
|
?SH-PROMPT
|
||||||
|
|
||||||
!cd emqx
|
!cd emqx
|
||||||
|
@ -30,6 +31,7 @@
|
||||||
?SH-PROMPT
|
?SH-PROMPT
|
||||||
|
|
||||||
[shell emqx2]
|
[shell emqx2]
|
||||||
|
!OLD_VSN=$(echo $OLD_VSN | sed -r 's/[v|e]//g')
|
||||||
!cd $PACKAGE_PATH
|
!cd $PACKAGE_PATH
|
||||||
!cp -f $ONE_MORE_EMQX_PATH/one_more_$(echo $PROFILE | sed 's/-/_/g').sh .
|
!cp -f $ONE_MORE_EMQX_PATH/one_more_$(echo $PROFILE | sed 's/-/_/g').sh .
|
||||||
!./one_more_$(echo $PROFILE | sed 's/-/_/g').sh emqx2
|
!./one_more_$(echo $PROFILE | sed 's/-/_/g').sh emqx2
|
||||||
|
@ -82,6 +84,27 @@
|
||||||
|
|
||||||
!cp -f ../$PROFILE-ubuntu20.04-$VSN-amd64.zip releases/
|
!cp -f ../$PROFILE-ubuntu20.04-$VSN-amd64.zip releases/
|
||||||
|
|
||||||
|
## upgrade to the new version
|
||||||
|
!./bin/emqx install $VSN
|
||||||
|
?Made release permanent: "$VSN"
|
||||||
|
?SH-PROMPT
|
||||||
|
|
||||||
|
!./bin/emqx versions |grep permanent
|
||||||
|
?(.*)$VSN
|
||||||
|
?SH-PROMPT
|
||||||
|
|
||||||
|
## downgrade to the old version
|
||||||
|
!./bin/emqx install $${OLD_VSN}
|
||||||
|
?Made release permanent:.*
|
||||||
|
?SH-PROMPT
|
||||||
|
|
||||||
|
!./bin/emqx versions |grep permanent | grep -qs "$${OLD_VSN}"
|
||||||
|
?SH-PROMPT:
|
||||||
|
!echo ==$$?==
|
||||||
|
?^==0==
|
||||||
|
?SH-PROMPT:
|
||||||
|
|
||||||
|
## again, upgrade to the new version
|
||||||
!./bin/emqx install $VSN
|
!./bin/emqx install $VSN
|
||||||
?Made release permanent: "$VSN"
|
?Made release permanent: "$VSN"
|
||||||
?SH-PROMPT
|
?SH-PROMPT
|
||||||
|
@ -107,6 +130,27 @@
|
||||||
|
|
||||||
!cp -f ../$PROFILE-ubuntu20.04-$VSN-amd64.zip releases/
|
!cp -f ../$PROFILE-ubuntu20.04-$VSN-amd64.zip releases/
|
||||||
|
|
||||||
|
## upgrade to the new version
|
||||||
|
!./bin/emqx install $VSN
|
||||||
|
?Made release permanent: "$VSN"
|
||||||
|
?SH-PROMPT
|
||||||
|
|
||||||
|
!./bin/emqx versions |grep permanent
|
||||||
|
?(.*)$VSN
|
||||||
|
?SH-PROMPT
|
||||||
|
|
||||||
|
## downgrade to the old version
|
||||||
|
!./bin/emqx install $${OLD_VSN}
|
||||||
|
?Made release permanent:.*
|
||||||
|
?SH-PROMPT
|
||||||
|
|
||||||
|
!./bin/emqx versions |grep permanent | grep -qs "$${OLD_VSN}"
|
||||||
|
?SH-PROMPT:
|
||||||
|
!echo ==$$?==
|
||||||
|
?^==0==
|
||||||
|
?SH-PROMPT:
|
||||||
|
|
||||||
|
## again, upgrade to the new version
|
||||||
!./bin/emqx install $VSN
|
!./bin/emqx install $VSN
|
||||||
?Made release permanent: "$VSN"
|
?Made release permanent: "$VSN"
|
||||||
?SH-PROMPT
|
?SH-PROMPT
|
||||||
|
@ -136,17 +180,20 @@
|
||||||
!./bin/emqx_ctl broker metrics | grep "messages.publish"
|
!./bin/emqx_ctl broker metrics | grep "messages.publish"
|
||||||
???SH-PROMPT
|
???SH-PROMPT
|
||||||
|
|
||||||
|
## We don't guarantee not to lose a single message!
|
||||||
|
## So even if we received 290~300 messages, we consider it as success
|
||||||
[shell bench]
|
[shell bench]
|
||||||
!curl --user admin:public --silent --show-error http://localhost:8081/api/v4/rules | jq -M --raw-output ".data[0].metrics[] | select(.node==\"emqx@127.0.0.1\").matched"
|
!curl --user admin:public --silent --show-error http://localhost:8081/api/v4/rules | jq -M --raw-output ".data[0].metrics[] | select(.node==\"emqx@127.0.0.1\").matched"
|
||||||
?300
|
?(29[0-9])|(300)
|
||||||
?SH-PROMPT
|
?SH-PROMPT
|
||||||
|
|
||||||
!curl --user admin:public --silent --show-error http://localhost:8081/api/v4/rules | jq -M --raw-output ".data[0].actions[0].metrics[] | select(.node==\"emqx@127.0.0.1\").success"
|
!curl --user admin:public --silent --show-error http://localhost:8081/api/v4/rules | jq -M --raw-output ".data[0].actions[0].metrics[] | select(.node==\"emqx@127.0.0.1\").success"
|
||||||
?300
|
?(29[0-9])|(300)
|
||||||
?SH-PROMPT
|
?SH-PROMPT
|
||||||
|
|
||||||
|
## The /counter API is provided by .ci/fvt_test/http_server
|
||||||
!curl http://127.0.0.1:8080/counter
|
!curl http://127.0.0.1:8080/counter
|
||||||
???{"data":300,"code":0}
|
?\{"data":(29[0-9])|(300),"code":0\}
|
||||||
?SH-PROMPT
|
?SH-PROMPT
|
||||||
|
|
||||||
[shell emqx2]
|
[shell emqx2]
|
||||||
|
|
|
@ -26,6 +26,7 @@ File format:
|
||||||
|
|
||||||
### Bug fixes
|
### Bug fixes
|
||||||
|
|
||||||
|
* Fix the `{error,eexist}` error when do release upgrade again if last run failed. [#7121]
|
||||||
* Fix case where publishing to a non-existent topic alias would crash the connection [#6979]
|
* Fix case where publishing to a non-existent topic alias would crash the connection [#6979]
|
||||||
* Fix HTTP-API 500 error on querying the lwm2m client list on the another node [#7009]
|
* Fix HTTP-API 500 error on querying the lwm2m client list on the another node [#7009]
|
||||||
* Fix the ExProto connection registry is not released after the client process abnormally exits [#6983]
|
* Fix the ExProto connection registry is not released after the client process abnormally exits [#6983]
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
-define(TIMEOUT, 300000).
|
-define(TIMEOUT, 300000).
|
||||||
-define(INFO(Fmt,Args), io:format(Fmt++"~n",Args)).
|
-define(INFO(Fmt,Args), io:format(Fmt++"~n",Args)).
|
||||||
|
|
||||||
|
-mode(compile).
|
||||||
|
|
||||||
main([Command0, DistInfoStr | CommandArgs]) ->
|
main([Command0, DistInfoStr | CommandArgs]) ->
|
||||||
%% convert the distribution info arguments string to an erlang term
|
%% convert the distribution info arguments string to an erlang term
|
||||||
{ok, Tokens, _} = erl_scan:string(DistInfoStr ++ "."),
|
{ok, Tokens, _} = erl_scan:string(DistInfoStr ++ "."),
|
||||||
|
@ -210,15 +212,24 @@ find_and_link_release_package(Version, RelName) ->
|
||||||
ok = filelib:ensure_dir(filename:join([filename:dirname(ReleaseLink), "dummy"])),
|
ok = filelib:ensure_dir(filename:join([filename:dirname(ReleaseLink), "dummy"])),
|
||||||
%% create the symlink pointing to the full path name of the
|
%% create the symlink pointing to the full path name of the
|
||||||
%% release package we found
|
%% release package we found
|
||||||
case file:make_symlink(filename:absname(Filename), ReleaseLink) of
|
make_symlink_or_copy(filename:absname(Filename), ReleaseLink),
|
||||||
ok ->
|
|
||||||
ok;
|
|
||||||
{error, eperm} -> % windows!
|
|
||||||
{ok,_} = file:copy(filename:absname(Filename), ReleaseLink)
|
|
||||||
end,
|
|
||||||
{Filename, ReleaseHandlerPackageLink}
|
{Filename, ReleaseHandlerPackageLink}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
make_symlink_or_copy(Filename, ReleaseLink) ->
|
||||||
|
case file:make_symlink(Filename, ReleaseLink) of
|
||||||
|
ok -> ok;
|
||||||
|
{error, eexist} ->
|
||||||
|
?INFO("symlink ~p already exists, recreate it", [ReleaseLink]),
|
||||||
|
ok = file:delete(ReleaseLink),
|
||||||
|
make_symlink_or_copy(Filename, ReleaseLink);
|
||||||
|
{error, Reason} when Reason =:= eperm; Reason =:= enotsup ->
|
||||||
|
{ok, _} = file:copy(Filename, ReleaseLink);
|
||||||
|
{error, Reason} ->
|
||||||
|
?INFO("create symlink ~p failed", [ReleaseLink]),
|
||||||
|
error({Reason, ReleaseLink})
|
||||||
|
end.
|
||||||
|
|
||||||
unpack_zipballs(RelNameStr, Version) ->
|
unpack_zipballs(RelNameStr, Version) ->
|
||||||
{ok, Cwd} = file:get_cwd(),
|
{ok, Cwd} = file:get_cwd(),
|
||||||
GzFile = filename:absname(filename:join(["releases", RelNameStr ++ "-" ++ Version ++ ".tar.gz"])),
|
GzFile = filename:absname(filename:join(["releases", RelNameStr ++ "-" ++ Version ++ ".tar.gz"])),
|
||||||
|
|
Loading…
Reference in New Issue