From b6540b60fa0dba73d247b938477b19bf50f3e07f Mon Sep 17 00:00:00 2001 From: Gabor Pali Date: Fri, 24 Feb 2023 12:38:37 +0100 Subject: [PATCH] Introduce ad-hoc Erlang cookie configuration for the `dev` scripts Extend the `dev/run` and `dev/remsh` scripts in ways that would let the users to set the cookie for inter-node communication directly from the command line. This may come handy in certain cases, e.g. when there is a specific Clouseau instance to hook up. --- dev/remsh | 8 +++++++- dev/remsh-tls | 8 +++++++- dev/run | 9 +++++++++ rel/overlay/etc/vm.args | 3 +-- 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/dev/remsh b/dev/remsh index 347a799d088..65b999517a6 100755 --- a/dev/remsh +++ b/dev/remsh @@ -23,6 +23,12 @@ if [ -z $HOST ]; then HOST="127.0.0.1" fi +if [ -n "$COOKIE" ]; then + _cookie_flag="-setcookie $COOKIE" +else + _cookie_flag="" +fi + NAME="remsh$$@$HOST" NODE="node$NODE@$HOST" -erl -name $NAME -remsh $NODE -hidden +erl -name $NAME -remsh $NODE -hidden ${_cookie_flag} diff --git a/dev/remsh-tls b/dev/remsh-tls index 089db669f44..d420a20a6d4 100755 --- a/dev/remsh-tls +++ b/dev/remsh-tls @@ -23,7 +23,13 @@ if [ -z $HOST ]; then HOST="127.0.0.1" fi +if [ -n "$COOKIE" ]; then + _cookie_flag="-setcookie $COOKIE" +else + _cookie_flag="" +fi + NAME="remsh$$@$HOST" NODE="node$NODE@$HOST" rootdir="$(cd "${0%/*}" 2>/dev/null; echo "$PWD")" -erl -name $NAME -remsh $NODE -hidden -proto_dist inet_tls -ssl_dist_optfile "${rootdir}/couch_ssl_dist.conf" +erl -name $NAME -remsh $NODE -hidden -proto_dist inet_tls -ssl_dist_optfile "${rootdir}/couch_ssl_dist.conf" ${_cookie_flag} diff --git a/dev/run b/dev/run index df1a0b10574..12571c44703 100755 --- a/dev/run +++ b/dev/run @@ -226,6 +226,12 @@ def get_args_parser(): default=[], help="Path to config to place in 'local.d'. Can be repeated", ) + parser.add_option( + "--erlang-cookie", + metavar="COOKIE_STRING", + dest="erlang_cookie", + help="Set Erlang cookie explicitly for inter-node communication", + ) return parser @@ -255,6 +261,7 @@ def setup_context(opts, args): "procs": [], "auto_ports": opts.auto_ports, "locald_configs": opts.locald_configs, + "erlang_cookie": opts.erlang_cookie, } @@ -290,6 +297,7 @@ def setup_configs(ctx): cluster_port, backend_port, prometheus_port = get_ports( ctx, idx + ctx["node_number"] ) + cookie = ctx["erlang_cookie"] env = { "prefix": toposixpath(ctx["rootdir"]), "package_author_name": "The Apache Software Foundation", @@ -303,6 +311,7 @@ def setup_configs(ctx): ensure_dir_exists(ctx["devdir"], "lib", node, "data") ), "node_name": "-name %s@127.0.0.1" % node, + "erlang_cookie": "-setcookie %s" % cookie if cookie else "", "cluster_port": cluster_port, "backend_port": backend_port, "prometheus_port": prometheus_port, diff --git a/rel/overlay/etc/vm.args b/rel/overlay/etc/vm.args index 2c011e4057f..1617c03c713 100644 --- a/rel/overlay/etc/vm.args +++ b/rel/overlay/etc/vm.args @@ -38,8 +38,7 @@ {{node_name}} # All nodes must share the same magic cookie for distributed Erlang to work. -# Uncomment the following line and append a securely generated random value. -# -setcookie +{{erlang_cookie}} # Which interfaces should the node listen on? -kernel inet_dist_use_interface {127,0,0,1}