Skip to content

Commit 658d9c7

Browse files
committed
Upgrade eetcd and gun
## Why? To introduce AMQP over WebSocket, we will add gun to the Erlang AMQP 1.0 client. We want to add the latest version of gun for this new feature. Since rabbitmq_peer_discovery_etcd depends on the outdated eetcd 0.3.6 which in turn depends on the outdated gun 1.3.3, this commit first upgrades eetcd and gun. ## How? See https://github.com/zhongwencool/eetcd?tab=readme-ov-file#migration-from-eetcd-03x-to-04x ## Breaking Changes This commit causes the following breaking change: `rabbitmq.conf` settings * `cluster_formation.etcd.ssl_options.fail_if_no_peer_cert` * `cluster_formation.etcd.ssl_options.dh` * `cluster_formation.etcd.ssl_options.dhfile` are unsupported because they are not valid `ssl:tls_client_option()`. See erlang/otp#7497 (comment)
1 parent 85ec8e0 commit 658d9c7

File tree

4 files changed

+36
-42
lines changed

4 files changed

+36
-42
lines changed

deps/rabbitmq_peer_discovery_etcd/Makefile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ PROJECT_MOD = rabbitmq_peer_discovery_etcd_app
55
DEPS = rabbit_common rabbitmq_peer_discovery_common rabbit eetcd gun
66
TEST_DEPS = rabbitmq_ct_helpers rabbitmq_ct_client_helpers ct_helper meck
77
dep_ct_helper = git https://github.com/extend/ct_helper.git master
8-
dep_gun = hex 1.3.3
9-
dep_eetcd = hex 0.3.6
8+
dep_gun = hex 2.1.0
9+
dep_eetcd = hex 0.4.0
1010

1111
DEP_EARLY_PLUGINS = rabbit_common/mk/rabbitmq-early-plugin.mk
1212
DEP_PLUGINS = rabbit_common/mk/rabbitmq-plugin.mk

deps/rabbitmq_peer_discovery_etcd/priv/schema/rabbitmq_peer_discovery_etcd.schema

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,6 @@ end}.
182182
{mapping, "cluster_formation.etcd.ssl_options.verify", "rabbit.cluster_formation.peer_discovery_etcd.ssl_options.verify", [
183183
{datatype, {enum, [verify_peer, verify_none]}}]}.
184184

185-
{mapping, "cluster_formation.etcd.ssl_options.fail_if_no_peer_cert", "rabbit.cluster_formation.peer_discovery_etcd.ssl_options.fail_if_no_peer_cert", [
186-
{datatype, {enum, [true, false]}}]}.
187-
188185
{mapping, "cluster_formation.etcd.ssl_options.cacertfile", "rabbit.cluster_formation.peer_discovery_etcd.ssl_options.cacertfile",
189186
[{datatype, string}, {validators, ["file_accessible"]}]}.
190187

@@ -214,17 +211,6 @@ end}.
214211
{mapping, "cluster_formation.etcd.ssl_options.depth", "rabbit.cluster_formation.peer_discovery_etcd.ssl_options.depth",
215212
[{datatype, integer}, {validators, ["byte"]}]}.
216213

217-
{mapping, "cluster_formation.etcd.ssl_options.dh", "rabbit.cluster_formation.peer_discovery_etcd.ssl_options.dh",
218-
[{datatype, string}]}.
219-
220-
{translation, "rabbit.cluster_formation.peer_discovery_etcd.ssl_options.dh",
221-
fun(Conf) ->
222-
list_to_binary(cuttlefish:conf_get("cluster_formation.etcd.ssl_options.dh", Conf))
223-
end}.
224-
225-
{mapping, "cluster_formation.etcd.ssl_options.dhfile", "rabbit.cluster_formation.peer_discovery_etcd.ssl_options.dhfile",
226-
[{datatype, string}, {validators, ["file_accessible"]}]}.
227-
228214
{mapping, "cluster_formation.etcd.ssl_options.key.RSAPrivateKey", "rabbit.cluster_formation.peer_discovery_etcd.ssl_options.key",
229215
[{datatype, string}]}.
230216

deps/rabbitmq_peer_discovery_etcd/src/rabbitmq_peer_discovery_etcd_v3_client.erl

Lines changed: 28 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -140,18 +140,12 @@ recover(internal, start, Data = #statem_data{endpoints = Endpoints, connection_m
140140
rabbit_log:debug("etcd v3 API client will attempt to connect, endpoints: ~ts",
141141
[string:join(Endpoints, ",")]),
142142
maybe_demonitor(Ref),
143-
{Transport, TransportOpts} = pick_transport(Data),
144-
case Transport of
145-
tcp -> rabbit_log:info("etcd v3 API client is configured to connect over plain TCP, without using TLS");
146-
tls -> rabbit_log:info("etcd v3 API client is configured to use TLS")
147-
end,
148-
ConnName = ?ETCD_CONN_NAME,
149-
case connect(ConnName, Endpoints, Transport, TransportOpts, Data) of
143+
case connect(?ETCD_CONN_NAME, Endpoints, Data) of
150144
{ok, Pid} ->
151145
rabbit_log:debug("etcd v3 API client connection: ~tp", [Pid]),
152146
rabbit_log:debug("etcd v3 API client: total number of connections to etcd is ~tp", [length(eetcd_conn_sup:info())]),
153147
{next_state, connected, Data#statem_data{
154-
connection_name = ConnName,
148+
connection_name = ?ETCD_CONN_NAME,
155149
connection_pid = Pid,
156150
connection_monitor = monitor(process, Pid)
157151
}};
@@ -324,20 +318,21 @@ error_is_already_started({_Endpoint, already_started}) ->
324318
error_is_already_started({_Endpoint, _}) ->
325319
false.
326320

327-
connect(Name, Endpoints, Transport, TransportOpts, Data) ->
321+
connect(Name, Endpoints, Data) ->
328322
case eetcd_conn:lookup(Name) of
329323
{ok, Pid} when is_pid(Pid) ->
330324
{ok, Pid};
331325
{error, eetcd_conn_unavailable} ->
332-
do_connect(Name, Endpoints, Transport, TransportOpts, Data)
326+
do_connect(Name, Endpoints, Data)
333327
end.
334328

335-
do_connect(Name, Endpoints, Transport, TransportOpts, Data = #statem_data{username = Username}) ->
329+
do_connect(Name, Endpoints, Data = #statem_data{username = Username}) ->
330+
Opts = connection_options(Data),
336331
case Username of
337332
undefined -> rabbit_log:info("etcd peer discovery: will connect to etcd without authentication (no credentials configured)");
338333
_ -> rabbit_log:info("etcd peer discovery: will connect to etcd as user '~ts'", [Username])
339334
end,
340-
case eetcd:open(Name, Endpoints, connection_options(Data), Transport, TransportOpts) of
335+
case eetcd:open(Name, Endpoints, Opts) of
341336
{ok, Pid} -> {ok, Pid};
342337
{error, Errors0} ->
343338
Errors = case is_list(Errors0) of
@@ -358,16 +353,6 @@ do_connect(Name, Endpoints, Transport, TransportOpts, Data = #statem_data{userna
358353
end
359354
end.
360355

361-
connection_options(#statem_data{username = Username, obfuscated_password = Password}) ->
362-
SharedOpts = [{mode, random}],
363-
case {Username, Password} of
364-
{undefined, _} -> SharedOpts;
365-
{_, undefined} -> SharedOpts;
366-
{UVal, PVal} ->
367-
[{name, UVal}, {password, to_list(deobfuscate(PVal))}] ++ SharedOpts
368-
end.
369-
370-
371356
obfuscate(undefined) -> undefined;
372357
obfuscate(Password) ->
373358
credentials_obfuscation:encrypt(to_binary(Password)).
@@ -433,7 +418,24 @@ normalize_settings(Map) when is_map(Map) ->
433418
maps:merge(maps:without([etcd_prefix, lock_wait_time], Map),
434419
#{endpoints => AllEndpoints}).
435420

436-
pick_transport(#statem_data{tls_options = []}) ->
437-
{tcp, []};
438-
pick_transport(#statem_data{tls_options = Opts}) ->
439-
{tls, Opts}.
421+
connection_options(#statem_data{tls_options = TlsOpts,
422+
username = Username,
423+
obfuscated_password = Password}) ->
424+
Opts0 = case TlsOpts of
425+
[] ->
426+
rabbit_log:info("etcd v3 API client is configured to use plain TCP (without TLS)"),
427+
[{transport, tcp}];
428+
_ ->
429+
rabbit_log:info("etcd v3 API client is configured to use TLS"),
430+
[{transport, tls},
431+
{tls_opts, TlsOpts}]
432+
end,
433+
Opts = [{mode, random} | Opts0],
434+
case Username =:= undefined orelse
435+
Password =:= undefined of
436+
true ->
437+
Opts;
438+
false ->
439+
[{name, Username},
440+
{password, to_list(deobfuscate(Password))}] ++ Opts
441+
end.

release-notes/4.1.0.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ for the complete list of related changes.
3232
This default can be overridden by [configuring](https://www.rabbitmq.com/docs/configure#config-file) `mqtt.max_packet_size_authenticated`.
3333
Note that this value must not be greater than `max_message_size` (which also defaults to 16 MiB).
3434

35+
### etcd Peer Discovery
36+
37+
The following `rabbitmq.conf` settings are unsupported:
38+
* `cluster_formation.etcd.ssl_options.fail_if_no_peer_cert`
39+
* `cluster_formation.etcd.ssl_options.dh`
40+
* `cluster_formation.etcd.ssl_options.dhfile`
3541

3642
## Erlang/OTP Compatibility Notes
3743

0 commit comments

Comments
 (0)