This repository has been archived by the owner on Sep 27, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 96
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | ||
|
||
|