Merge pull request #13201 from rabbitmq/rabbitmq-server-13194
By @frederikbosch: Peer discovery: add an option to opt out of registration
This commit is contained in:
commit
491971f08d
|
|
@ -1370,6 +1370,13 @@ fun(Conf) ->
|
|||
end
|
||||
end}.
|
||||
|
||||
%% Register node during cluster formation when backend supports registration.
|
||||
%%
|
||||
|
||||
{mapping, "cluster_formation.registration.enabled", "rabbit.cluster_formation.perform_registration", [
|
||||
{datatype, {enum, [true, false]}}
|
||||
]}.
|
||||
|
||||
%% Cluster formation: lock acquisition retries as passed to https://erlang.org/doc/man/global.html#set_lock-3
|
||||
%%
|
||||
%% Currently used in classic, k8s, and aws peer discovery backends.
|
||||
|
|
|
|||
|
|
@ -46,6 +46,9 @@
|
|||
%% a new cluster as a virgin node
|
||||
-define(DEFAULT_NODE_TYPE, disc).
|
||||
|
||||
%% Register node by default (with the backends that support registration)
|
||||
-define(PERFORM_REGISTRATION_BY_DEFAULT, true).
|
||||
|
||||
%% default node prefix to attach to discovered hostnames
|
||||
-define(DEFAULT_PREFIX, "rabbit").
|
||||
|
||||
|
|
@ -82,6 +85,16 @@ node_type() ->
|
|||
?DEFAULT_NODE_TYPE
|
||||
end.
|
||||
|
||||
-spec should_perform_registration() -> true | false.
|
||||
|
||||
should_perform_registration() ->
|
||||
case application:get_env(rabbit, cluster_formation) of
|
||||
{ok, Proplist} ->
|
||||
proplists:get_value(perform_registration, Proplist, ?PERFORM_REGISTRATION_BY_DEFAULT);
|
||||
undefined ->
|
||||
?PERFORM_REGISTRATION_BY_DEFAULT
|
||||
end.
|
||||
|
||||
-spec lock_acquisition_failure_mode() -> ignore | fail.
|
||||
|
||||
lock_acquisition_failure_mode() ->
|
||||
|
|
@ -968,18 +981,26 @@ error_description({invalid_cluster_node_type, BadType}) ->
|
|||
-spec maybe_register() -> ok.
|
||||
|
||||
maybe_register() ->
|
||||
Backend = persistent_term:get(?PT_PEER_DISC_BACKEND, backend()),
|
||||
case Backend:supports_registration() of
|
||||
case should_perform_registration() of
|
||||
true ->
|
||||
?LOG_DEBUG(
|
||||
"Peer discovery: registering this node",
|
||||
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
|
||||
register(Backend),
|
||||
_ = Backend:post_registration(),
|
||||
ok;
|
||||
Backend = persistent_term:get(?PT_PEER_DISC_BACKEND, backend()),
|
||||
case Backend:supports_registration() of
|
||||
true ->
|
||||
?LOG_DEBUG(
|
||||
"Peer discovery: registering this node",
|
||||
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
|
||||
register(Backend),
|
||||
_ = Backend:post_registration(),
|
||||
ok;
|
||||
false ->
|
||||
?LOG_DEBUG(
|
||||
"Peer discovery: registration is not supported, skipping it",
|
||||
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
|
||||
ok
|
||||
end;
|
||||
false ->
|
||||
?LOG_DEBUG(
|
||||
"Peer discovery: registration unsupported, skipping register",
|
||||
"Peer discovery: registration is disabled via configuration, skipping it",
|
||||
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
|
||||
ok
|
||||
end.
|
||||
|
|
@ -987,16 +1008,24 @@ maybe_register() ->
|
|||
-spec maybe_unregister() -> ok.
|
||||
|
||||
maybe_unregister() ->
|
||||
Backend = persistent_term:get(?PT_PEER_DISC_BACKEND),
|
||||
case Backend:supports_registration() of
|
||||
case should_perform_registration() of
|
||||
true ->
|
||||
?LOG_DEBUG(
|
||||
"Peer discovery: unregistering this node",
|
||||
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
|
||||
unregister(Backend);
|
||||
Backend = persistent_term:get(?PT_PEER_DISC_BACKEND),
|
||||
case Backend:supports_registration() of
|
||||
true ->
|
||||
?LOG_DEBUG(
|
||||
"Peer discovery: unregistering this node",
|
||||
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
|
||||
unregister(Backend);
|
||||
false ->
|
||||
?LOG_DEBUG(
|
||||
"Peer discovery: registration is not supported, skipping unregistration",
|
||||
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
|
||||
ok
|
||||
end;
|
||||
false ->
|
||||
?LOG_DEBUG(
|
||||
"Peer discovery: registration unsupported, skipping unregister",
|
||||
"Peer discovery: registration is disabled via configuration, skipping unregistration",
|
||||
#{domain => ?RMQLOG_DOMAIN_PEER_DISC}),
|
||||
ok
|
||||
end.
|
||||
|
|
|
|||
|
|
@ -310,6 +310,25 @@ cluster_formation.dns.hostname = discovery.eng.example.local",
|
|||
]}],
|
||||
[]},
|
||||
|
||||
%% registration is enabled by default for the backends that support it
|
||||
{cluster_formation_explicitly_enable_of_registration,
|
||||
"cluster_formation.registration.enabled = true",
|
||||
[{rabbit,
|
||||
[{cluster_formation, [
|
||||
{perform_registration, true}
|
||||
]}]
|
||||
}],
|
||||
[]},
|
||||
|
||||
{cluster_formation_opt_out_of_registration,
|
||||
"cluster_formation.registration.enabled = false",
|
||||
[{rabbit,
|
||||
[{cluster_formation, [
|
||||
{perform_registration, false}
|
||||
]}]
|
||||
}],
|
||||
[]},
|
||||
|
||||
{tcp_listen_options,
|
||||
"tcp_listen_options.backlog = 128
|
||||
tcp_listen_options.nodelay = true
|
||||
|
|
|
|||
Loading…
Reference in New Issue