Skip to content

Commit d32660c

Browse files
committed
rabbitmq-env: Pass remote node name ro child rabbitmqctl(8)
We use rabbitmqctl(8) inside `rabbitmq-env` to query the settings of the remote nodes (path to plugins, feature flags file, the database, etc). However, before this patch, we didn't pass the name of the remote node as specified by the user with `-n`. Therefore, the default node name was used (`rabbit@$hostname`) and that node may not exist at all. This caused the executed script to run with possibly incorrect settings. In particular, this prevented rabbitmq-plugins(8) from working properly on a node started with `gmake run-broker`. This should now be fixed because we extract the remote node name from the command line arguments and pass it to the child rabbitmqctl(8).
1 parent 8f7b78c commit d32660c

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

scripts/rabbitmq-env

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -330,7 +330,22 @@ if [ "${RABBITMQ_DEV_ENV}" ]; then
330330
"$RABBITMQ_ENABLED_PLUGINS_FILE_source" != 'environment' ]; then
331331
# We need to query the running node for the plugins directory
332332
# and the "enabled plugins" file.
333-
eval $( (${RABBITMQ_SCRIPTS_DIR}/rabbitmqctl eval \
333+
for arg in "$@"; do
334+
case "$arg" in
335+
-n)
336+
next_is_node=1
337+
;;
338+
*)
339+
if test "$next_is_node"; then
340+
# If the executed script is being passed a remote node
341+
# name, use it here to query the remote node.
342+
node_arg="-n $arg"
343+
break
344+
fi
345+
;;
346+
esac
347+
done
348+
eval $( (${RABBITMQ_SCRIPTS_DIR}/rabbitmqctl $node_arg eval \
334349
'{ok, F} = application:get_env(rabbit, feature_flags_file),
335350
{ok, P} = application:get_env(rabbit, plugins_dir),
336351
{ok, E} = application:get_env(rabbit, enabled_plugins_file),

0 commit comments

Comments
 (0)