Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce ad-hoc Erlang cookie configuration for the dev scripts #4445

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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=""
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason for the else clause when empty is the default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, there is not any :-) Thanks for catching this.

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 %[email protected]" % 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}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,

can this change break "couchdb-pkg" somewhere, if we are maybe grepping for "-setcookie"? @rnewson

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not worked with couchdb-pkg before but I can verify this concern there.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @jan for the references.

Copy link
Member

@rnewson rnewson Aug 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The package scripts should be (needs to be) robust against this kind of thing and I believe they are.

If the commented-out setcookie line is no longer present after this change the packaging scripts will append a setcookie line to the end of the file. That's less tidy than it being where we planned for it to be, but it will still work.

I would, however, prefer for this change not to have unintended side-effects at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed.


# Which interfaces should the node listen on?
-kernel inet_dist_use_interface {127,0,0,1}
Expand Down