Skip to content

Commit 815b182

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). (cherry picked from commit d32660c)
1 parent a1b8d69 commit 815b182

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
@@ -322,7 +322,22 @@ if [ "${RABBITMQ_DEV_ENV}" ]; then
322322
"$RABBITMQ_ENABLED_PLUGINS_FILE_source" != 'environment' ]; then
323323
# We need to query the running node for the plugins directory
324324
# and the "enabled plugins" file.
325-
eval $( (${RABBITMQ_SCRIPTS_DIR}/rabbitmqctl eval \
325+
for arg in "$@"; do
326+
case "$arg" in
327+
-n)
328+
next_is_node=1
329+
;;
330+
*)
331+
if test "$next_is_node"; then
332+
# If the executed script is being passed a remote node
333+
# name, use it here to query the remote node.
334+
node_arg="-n $arg"
335+
break
336+
fi
337+
;;
338+
esac
339+
done
340+
eval $( (${RABBITMQ_SCRIPTS_DIR}/rabbitmqctl $node_arg eval \
326341
'{ok, P} = application:get_env(rabbit, plugins_dir),
327342
{ok, E} = application:get_env(rabbit, enabled_plugins_file),
328343
B = os:getenv("RABBITMQ_MNESIA_BASE"),

0 commit comments

Comments
 (0)