Skip to content

Commit 143f4db

Browse files
authored
Merge pull request #12980 from rabbitmq/upgrade-gun
Upgrade eetcd and gun
2 parents d8ca61c + 658d9c7 commit 143f4db

File tree

4 files changed

+44
-46
lines changed

4 files changed

+44
-46
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: 36 additions & 30 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
}};
@@ -213,8 +207,12 @@ connected({call, From}, {unlock, GeneratedKey}, Data = #statem_data{connection_n
213207
connected({call, From}, register, Data = #statem_data{connection_name = Conn}) ->
214208
Ctx = registration_context(Conn, Data),
215209
Key = node_key(Data),
216-
eetcd_kv:put(Ctx, Key, registration_value(Data)),
217-
rabbit_log:debug("etcd peer discovery: put key ~tp, done with registration", [Key]),
210+
case eetcd_kv:put(Ctx, Key, registration_value(Data)) of
211+
{ok, _} ->
212+
rabbit_log:debug("etcd peer discovery: put key ~tp, done with registration", [Key]);
213+
{error, Reason} ->
214+
rabbit_log:error("etcd peer discovery: put key ~tp failed: ~p", [Key, Reason])
215+
end,
218216
gen_statem:reply(From, ok),
219217
keep_state_and_data;
220218
connected({call, From}, unregister, Data = #statem_data{connection_name = Conn}) ->
@@ -320,20 +318,21 @@ error_is_already_started({_Endpoint, already_started}) ->
320318
error_is_already_started({_Endpoint, _}) ->
321319
false.
322320

323-
connect(Name, Endpoints, Transport, TransportOpts, Data) ->
321+
connect(Name, Endpoints, Data) ->
324322
case eetcd_conn:lookup(Name) of
325323
{ok, Pid} when is_pid(Pid) ->
326324
{ok, Pid};
327325
{error, eetcd_conn_unavailable} ->
328-
do_connect(Name, Endpoints, Transport, TransportOpts, Data)
326+
do_connect(Name, Endpoints, Data)
329327
end.
330328

331-
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),
332331
case Username of
333332
undefined -> rabbit_log:info("etcd peer discovery: will connect to etcd without authentication (no credentials configured)");
334333
_ -> rabbit_log:info("etcd peer discovery: will connect to etcd as user '~ts'", [Username])
335334
end,
336-
case eetcd:open(Name, Endpoints, connection_options(Data), Transport, TransportOpts) of
335+
case eetcd:open(Name, Endpoints, Opts) of
337336
{ok, Pid} -> {ok, Pid};
338337
{error, Errors0} ->
339338
Errors = case is_list(Errors0) of
@@ -354,16 +353,6 @@ do_connect(Name, Endpoints, Transport, TransportOpts, Data = #statem_data{userna
354353
end
355354
end.
356355

357-
connection_options(#statem_data{username = Username, obfuscated_password = Password}) ->
358-
SharedOpts = [{mode, random}],
359-
case {Username, Password} of
360-
{undefined, _} -> SharedOpts;
361-
{_, undefined} -> SharedOpts;
362-
{UVal, PVal} ->
363-
[{name, UVal}, {password, to_list(deobfuscate(PVal))}] ++ SharedOpts
364-
end.
365-
366-
367356
obfuscate(undefined) -> undefined;
368357
obfuscate(Password) ->
369358
credentials_obfuscation:encrypt(to_binary(Password)).
@@ -379,9 +368,9 @@ disconnect(ConnName, #statem_data{connection_monitor = Ref}) ->
379368
unregister(Conn, Data = #statem_data{node_key_lease_id = LeaseID, node_lease_keepalive_pid = KAPid}) ->
380369
Ctx = unregistration_context(Conn, Data),
381370
Key = node_key(Data),
382-
eetcd_kv:delete(Ctx, Key),
371+
_ = eetcd_kv:delete(Ctx, Key),
383372
rabbit_log:debug("etcd peer discovery: deleted key ~ts, done with unregistration", [Key]),
384-
eetcd_lease:revoke(Ctx, LeaseID),
373+
_ = eetcd_lease:revoke(Ctx, LeaseID),
385374
exit(KAPid, normal),
386375
rabbit_log:debug("etcd peer discovery: revoked a lease ~tp for node key ~ts", [LeaseID, Key]),
387376
ok.
@@ -429,7 +418,24 @@ normalize_settings(Map) when is_map(Map) ->
429418
maps:merge(maps:without([etcd_prefix, lock_wait_time], Map),
430419
#{endpoints => AllEndpoints}).
431420

432-
pick_transport(#statem_data{tls_options = []}) ->
433-
{tcp, []};
434-
pick_transport(#statem_data{tls_options = Opts}) ->
435-
{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)