summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Lebedeff <alebedev@mirantis.com>2016-06-30 19:29:04 +0300
committerAlexey Lebedeff <alebedev@mirantis.com>2016-06-30 19:45:06 +0300
commit1e3810ad57e6db46265b1324b3908122f613d13e (patch)
tree370b795dc0cc9bf4a07acaa8c5675750df08512d
parentef4146b4823f56bc8cd6c8509a4c9a32682fceea (diff)
downloadrabbitmq-server-git-1e3810ad57e6db46265b1324b3908122f613d13e.tar.gz
Report join_cluster errors more thoroughly
Because `{ok, _}` should mean OK, and `{error, _}` should be a real error. With the addition of https://github.com/rabbitmq/rabbitmq-common/pull/115 `rabbitmqctl join_cluster` will become consistent.
-rw-r--r--src/rabbit_mnesia.erl25
1 files changed, 20 insertions, 5 deletions
diff --git a/src/rabbit_mnesia.erl b/src/rabbit_mnesia.erl
index c327b33e5d..f247757420 100644
--- a/src/rabbit_mnesia.erl
+++ b/src/rabbit_mnesia.erl
@@ -200,8 +200,17 @@ join_cluster(DiscoveryNode, NodeType) ->
{error, Reason}
end;
true ->
- rabbit_log:info("Already member of cluster: ~p~n", [ClusterNodes]),
- {ok, already_member}
+ %% DiscoveryNode thinks that we are part of a cluster, but
+ %% do we think so ourselves?
+ case are_we_clustered_with(DiscoveryNode) of
+ true ->
+ rabbit_log:info("Already member of cluster: ~p~n", [ClusterNodes]),
+ {ok, already_member};
+ false ->
+ Msg = format_inconsistent_cluster_message(DiscoveryNode, node()),
+ rabbit_log:error(Msg),
+ {error, {inconsistent_cluster, Msg}}
+ end
end.
%% return node to its virgin state, where it is not member of any
@@ -788,9 +797,7 @@ check_nodes_consistency(Node, RemoteStatus = {RemoteAllNodes, _, _}) ->
{ok, RemoteStatus};
false ->
{error, {inconsistent_cluster,
- rabbit_misc:format("Node ~p thinks it's clustered "
- "with node ~p, but ~p disagrees",
- [node(), Node, Node])}}
+ format_inconsistent_cluster_message(node(), Node)}}
end.
check_mnesia_or_otp_consistency(_Node, unsupported, OTP) ->
@@ -896,6 +903,9 @@ is_only_clustered_disc_node() ->
node_type() =:= disc andalso is_clustered() andalso
cluster_nodes(disc) =:= [node()].
+are_we_clustered_with(Node) ->
+ lists:member(Node, mnesia_lib:all_nodes()).
+
me_in_nodes(Nodes) -> lists:member(node(), Nodes).
nodes_incl_me(Nodes) -> lists:usort([node()|Nodes]).
@@ -946,3 +956,8 @@ error_description(removing_node_from_offline_node) ->
"from must be a disc node and all the other nodes must be offline.";
error_description(no_running_cluster_nodes) ->
"You cannot leave a cluster if no online nodes are present.".
+
+format_inconsistent_cluster_message(Thinker, Dissident) ->
+ rabbit_misc:format("Node ~p thinks it's clustered "
+ "with node ~p, but ~p disagrees",
+ [Thinker, Dissident, Dissident]).