Skip to content

Commit

Permalink
Merge pull request rabbitmq#11279 from rabbitmq/mk-start-virtual-host…
Browse files Browse the repository at this point in the history
…-on-an-arbitrary-set-of-nodes

Introduce rabbit_vhost_sup_sup:start_on_all_nodes/2
  • Loading branch information
michaelklishin authored May 20, 2024
2 parents 22b16a1 + f22a027 commit 81bcec4
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions deps/rabbit/src/rabbit_vhost_sup_sup.erl
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
save_vhost_recovery_terms/2,
lookup_vhost_sup_record/1,
lookup_vhost_recovery_terms/1]).
-export([delete_on_all_nodes/1, start_on_all_nodes/1]).
-export([delete_on_all_nodes/1, start_on_all_nodes/1, start_on_all_nodes/2]).
-export([is_vhost_alive/1]).
-export([check/0]).

Expand Down Expand Up @@ -54,16 +54,19 @@ init([]) ->
[rabbit_vhost_sup_wrapper, rabbit_vhost_sup]}]}}.

start_on_all_nodes(VHost) ->
%% Do not try to start a vhost on booting peer nodes
AllBooted = [Node || Node <- rabbit_nodes:list_running()],
%% By default select only fully booted peers
AllBooted = rabbit_nodes:list_running(),
Nodes = [node() | AllBooted],
start_on_all_nodes(VHost, Nodes).

start_on_all_nodes(VHost, Nodes) ->
Results = [{Node, start_vhost(VHost, Node)} || Node <- Nodes],
Failures = lists:filter(fun
({_, {ok, _}}) -> false;
({_, {error, {already_started, _}}}) -> false;
(_) -> true
end,
Results),
({_, {ok, _}}) -> false;
({_, {error, {already_started, _}}}) -> false;
(_) -> true
end,
Results),
case Failures of
[] -> ok;
Errors -> {error, {failed_to_start_vhost_on_nodes, Errors}}
Expand Down

0 comments on commit 81bcec4

Please sign in to comment.