Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mas i1121 reip3 #1838

Merged
merged 8 commits into from
Dec 6, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rebar.config
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
]}.

{deps, [
{riak_core, {git, "https://github.com/basho/riak_core.git", {tag, "riak_kv-3.0.10"}}},
{riak_core, {git, "https://github.com/basho/riak_core.git", {branch, "develop-3.0"}}},
{sidejob, {git, "https://github.com/basho/sidejob.git", {tag, "2.1.0"}}},
{bitcask, {git, "https://github.com/basho/bitcask.git", {tag, "2.1.0"}}},
{redbug, {git, "https://github.com/massemanet/redbug", {tag, "1.2.2"}}},
Expand Down
35 changes: 35 additions & 0 deletions src/riak_kv_console.erl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
status/1,
vnode_status/1,
reip/1,
reip_manual/1,
ringready/1,
cluster_info/1,
down/1,
Expand Down Expand Up @@ -232,6 +233,40 @@ reip([OldNode, NewNode]) ->
error
end.

reip_manual([OldNode, NewNode, Dir, ClusterName]) ->
try
%% reip/1 requires riak_core to be loaded to learn the Ring Directory
%% and the Cluster Name. In reip_manual/1 these can be passed in
%% instead
RingDir = atom_to_list(Dir),
Cluster = atom_to_list(ClusterName),
{ok, RingFile} =
riak_core_ring_manager:find_latest_ringfile(RingDir, Cluster),
io:format("~nCHANGE DETAILS:~n"),
io:format("RingFile to update ~p~n", [RingFile]),
BackupFN =
filename:join([RingDir, filename:basename(RingFile)++".BAK"]),
{ok, _} = file:copy(RingFile, BackupFN),
io:format("Backed up existing ring file to ~p~n", [BackupFN]),
Ring = riak_core_ring_manager:read_ringfile(RingFile),
NewRing = riak_core_ring:rename_node(Ring, OldNode, NewNode),
NewRingFN =
riak_core_ring_manager:generate_ring_filename(
RingDir, Cluster),
ok = riak_core_ring_manager:do_write_ringfile(NewRing, NewRingFN),
io:format("New ring file written to ~p~n", [NewRingFN]),
io:format("~nATTENTION REQUIRED:~n"),
io:format(
"Update required to riak.conf nodename before restarting node;"
++ " nodename should be changed to ~s~n",
[atom_to_list(NewNode)]),
io:format("~nok~n")
catch
Exception:Reason ->
io:format("Reip failed ~p:~p", [Exception, Reason]),
error
end.

%% Check if all nodes in the cluster agree on the partition assignment
-spec(ringready([]) -> ok | error).
ringready([]) ->
Expand Down