Skip to content

Commit 27b9027

Browse files
committed
rabbit_peer_discovery: Use alternative connection for the temporary hidden node
[Why] We want to make sure that the queried remote node doesn't know about the querying node. That's why we use a temporary hidden node in the first place. In fact, it is possible to start the temporary hidden node and communicate with it using an alternative connection instead of the regular Erlang distribution. This further ensures that the two RabbitMQ nodes don't connect to each other while properties are queried. [How] We use the `standard_io` alternative connection. We need to use `peer:call/4` instead of `erpc:call/4` to run code on the temporary hidden node. While here, we add assertions to verify that the three node didn't form a full mesh network at the end of the query code.
1 parent 8425afa commit 27b9027

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

deps/rabbit/src/rabbit_peer_discovery.erl

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -392,15 +392,16 @@ query_node_props(Nodes) when Nodes =/= [] ->
392392
VMArgs3 = maybe_add_proto_dist_arguments(VMArgs2),
393393
VMArgs4 = maybe_add_inetrc_arguments(VMArgs3),
394394
VMArgs5 = maybe_add_tls_arguments(VMArgs4),
395+
PeerStartArg0 = #{name => PeerName,
396+
args => VMArgs5,
397+
connection => standard_io,
398+
wait_boot => infinity},
395399
PeerStartArg = case Context of
396400
#{nodename_type := longnames} ->
397-
#{name => PeerName,
398-
host => Suffix,
399-
longnames => true,
400-
args => VMArgs5};
401+
PeerStartArg0#{host => Suffix,
402+
longnames => true};
401403
_ ->
402-
#{name => PeerName,
403-
args => VMArgs5}
404+
PeerStartArg0
404405
end,
405406
?LOG_DEBUG("Peer discovery: peer node arguments: ~tp",
406407
[PeerStartArg]),
@@ -412,7 +413,7 @@ query_node_props(Nodes) when Nodes =/= [] ->
412413
[Peer],
413414
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
414415
try
415-
erpc:call(Peer, ?MODULE, do_query_node_props, [Nodes])
416+
peer:call(Pid, ?MODULE, do_query_node_props, [Nodes], 180000)
416417
after
417418
peer:stop(Pid)
418419
end;
@@ -658,6 +659,8 @@ query_node_props2([], NodesAndProps, ProxyGroupLeader) ->
658659
after 120_000 ->
659660
ok
660661
end,
662+
?assertEqual([], nodes()),
663+
?assert(length(NodesAndProps2) =< length(nodes(hidden))),
661664
NodesAndProps2.
662665

663666
-spec get_node_start_time(Node, Unit, ProxyGroupLeader) -> StartTime when

0 commit comments

Comments
 (0)