aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuis Rascao <[email protected]>2016-10-31 09:38:56 +0000
committerLuis Rascao <[email protected]>2016-11-11 16:51:35 +0000
commit5b59fab481d2d4c72b391ea24bb1db8363ce25df (patch)
tree748fe6bacc5ca21b2e64cca83e1942388f12b04d
parentc305c89713abf48570e2db152b367f00ac641893 (diff)
downloadrelx-5b59fab481d2d4c72b391ea24bb1db8363ce25df.tar.gz
relx-5b59fab481d2d4c72b391ea24bb1db8363ce25df.tar.bz2
relx-5b59fab481d2d4c72b391ea24bb1db8363ce25df.zip
Allow upgrade/downgrade from non-permanent versions
Now that you can upgrade to a new version without setting it as permanent you should also be able to downgrade from it, this allows downgrading or upgrading to a version that is already marked as permanent but is not actually currently running.
-rw-r--r--priv/templates/install_upgrade_escript23
1 files changed, 22 insertions, 1 deletions
diff --git a/priv/templates/install_upgrade_escript b/priv/templates/install_upgrade_escript
index dc09f9c..c2aa06c 100644
--- a/priv/templates/install_upgrade_escript
+++ b/priv/templates/install_upgrade_escript
@@ -79,7 +79,18 @@ install({RelName, NameTypeArg, NodeName, Cookie}, Opts) ->
[Version])
end;
permanent ->
- ?INFO("Release ~s is already installed and set permanent.~n",[Version]);
+ %% this release is marked permanent, however it might not the
+ %% one currently running
+ case current_release_version(TargetNode) of
+ Version ->
+ ?INFO("Release ~s is already installed, running and set permanent.~n",
+ [Version]);
+ CurrentVersion ->
+ ?INFO("Release ~s is the currently running version.~n",
+ [CurrentVersion]),
+ check_and_install(TargetNode, Version),
+ maybe_permafy(TargetNode, RelName, Version, Opts)
+ end;
{error, Reason} ->
?INFO("Unpack failed: ~p~n",[Reason]),
print_existing_versions(TargetNode),
@@ -277,6 +288,16 @@ which_releases(TargetNode) ->
R = rpc:call(TargetNode, release_handler, which_releases, [], ?TIMEOUT),
[ {V, S} || {_,V,_, S} <- R ].
+%% the running release version is either the only one marked `current´
+%% or, if none exists, the one marked `permanent`
+current_release_version(TargetNode) ->
+ R = rpc:call(TargetNode, release_handler, which_releases,
+ [], ?TIMEOUT),
+ Versions = [ {S, V} || {_,V,_, S} <- R ],
+ %% current version takes priority over the permanent
+ proplists:get_value(current, Versions,
+ proplists:get_value(permanent, Versions)).
+
print_existing_versions(TargetNode) ->
VerList = iolist_to_binary([
io_lib:format("* ~s\t~s~n",[V,S])