Skip to content

Commit

Permalink
Introduce ad-hoc Erlang cookie configuration for the dev scripts
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
pgj committed Feb 24, 2023
1 parent cc674a8 commit 432f154
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 4 deletions.
8 changes: 7 additions & 1 deletion dev/remsh
Original file line number Diff line number Diff line change
Expand Up @@ -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}
8 changes: 7 additions & 1 deletion dev/remsh-tls
Original file line number Diff line number Diff line change
Expand Up @@ -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}
9 changes: 9 additions & 0 deletions dev/run
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down Expand Up @@ -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,
}


Expand Down Expand Up @@ -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",
Expand All @@ -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,
Expand Down
3 changes: 1 addition & 2 deletions rel/overlay/etc/vm.args
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit 432f154

Please sign in to comment.