chore: check ekka proto dist module type when resolving node address

Follow up to https://github.com/emqx/emqx/pull/11637#discussion_r1334462917

Fixes https://emqx.atlassian.net/browse/EMQX-10944
This commit is contained in:
Thales Macedo Garitezi 2023-09-22 16:23:39 -03:00
parent 5e400575e1
commit 806017ef90
2 changed files with 18 additions and 2 deletions

View File

@ -195,7 +195,8 @@ do_check({Node, #{resolved_ips := [IP | _]} = Plan}) ->
node_to_ips(Node) -> node_to_ips(Node) ->
NodeBin0 = atom_to_binary(Node), NodeBin0 = atom_to_binary(Node),
HostOrIP = re:replace(NodeBin0, <<"^.+@">>, <<"">>, [{return, list}]), HostOrIP = re:replace(NodeBin0, <<"^.+@">>, <<"">>, [{return, list}]),
case inet:gethostbyname(HostOrIP, inet) of AddressType = resolve_dist_address_type(),
case inet:gethostbyname(HostOrIP, AddressType) of
{ok, #hostent{h_addr_list = AddrList}} -> {ok, #hostent{h_addr_list = AddrList}} ->
AddrList; AddrList;
_ -> _ ->
@ -210,3 +211,18 @@ is_tcp_port_open(IP, Port) ->
_ -> _ ->
false false
end. end.
resolve_dist_address_type() ->
ProtoDistStr = os:getenv("EKKA_PROTO_DIST_MOD", "inet_tcp"),
case ProtoDistStr of
"inet_tcp" ->
inet;
"inet6_tcp" ->
inet6;
"inet_tls" ->
inet;
"inet6_tls" ->
inet6;
_ ->
inet
end.

View File

@ -170,7 +170,7 @@ t_open_ports_check(Config) ->
} }
}, },
erpc:call(Core1, emqx_machine, open_ports_check, []), erpc:call(Core1, emqx_machine, open_ports_check, []),
#{core2 => Core2} #{core2 => Core2, gen_rpc_port => GenRPCPort, ekka_port => EkkaPort}
), ),
ok. ok.