Skip to content
This repository has been archived by the owner on Sep 27, 2023. It is now read-only.

Commit

Permalink
Live upgrade procedure v69 -> v69.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ferd committed Aug 6, 2013
1 parent 62fadb9 commit 78cd11c
Showing 1 changed file with 54 additions and 0 deletions.
54 changes: 54 additions & 0 deletions upgrades/v69_v69.1/live_upgrade.erl
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
f(UpgradeNode).
UpgradeNode = fun () ->
case logplex_app:config(git_branch) of
"v69" ->
io:format(whereis(user), "at=upgrade_start cur_vsn=69~n", []);
"v69.1" ->
io:format(whereis(user),
"at=upgrade type=retry cur_vsn=69 old_vsn=69.1~n", []);
Else ->
io:format(whereis(user),
"at=upgrade_start old_vsn=~p abort=wrong_version", [tl(Else)]),
erlang:error({wrong_version, Else})
end,

%% stateless

% Minor changes to the logging/response order for performance
l(logplex_api),

application:set_env(logplex, git_branch, "v69.1"),
ok
end.

f(NodeVersions).
NodeVersions = fun () ->
lists:keysort(3,
[ {N,
element(2, rpc:call(N, application, get_env, [logplex, git_branch])),
rpc:call(N, os, getenv, ["INSTANCE_NAME"])}
|| N <- [node() | nodes()] ])
end.

f(NodesAt).
NodesAt = fun (Vsn) ->
[ N || {N, V, _} <- NodeVersions(), V =:= Vsn ]
end.


f(RollingUpgrade).
RollingUpgrade = fun (Nodes) ->
lists:foldl(fun (N, {good, Upgraded}) ->
case rpc:call(N, erlang, apply, [ UpgradeNode, [] ]) of
ok ->
{good, [N | Upgraded]};
Else ->
{{bad, N, Else}, Upgraded}
end;
(N, {_, _} = Acc) -> Acc
end,
{good, []},
Nodes)
end.


0 comments on commit 78cd11c

Please sign in to comment.