rabbitmq / rabbitmq-cli

Command line tools for RabbitMQ
Other
105 stars 34 forks source link

CLI will not pick up commands from implicitly enabled plugins #402

Closed lukebakken closed 4 years ago

lukebakken commented 4 years ago

To reproduce:

I see the same behavior using the zip package on Windows.

Running run-broker from master, I do see the plugin commands in the help output:

Management plugin:

   reset_stats_db                Resets statistics database. This will remove all metrics data!

Shovel plugin:

   delete_shovel                 Deletes a Shovel
   restart_shovel                Restarts a dynamic Shovel
   shovel_status                 Displays status of Shovel on a node

Use 'rabbitmqctl help <command>' to learn more about a specific command

Running them on a single node works. In a cluster, the full node name is required (including host name):

(22.2)lbakken@DSCH-WIN ~/development/rabbitmq/umbrella/deps/rabbitmq_server_release (master %=)
$ ./sbin/rabbitmqctl -n rabbit-1@DSCH-WIN shovel_status
Shovel status on node rabbit-1@DSCH-WIN

Otherwise:

(22.2)lbakken@DSCH-WIN ~/development/rabbitmq/umbrella/deps/rabbitmq_server_release (master %=)
$ ./sbin/rabbitmqctl -n rabbit-1 shovel_status

Command 'shovel_status' not found.
...
...
...

(Note: this may not be the correct repo for this issue)

michaelklishin commented 4 years ago

I can only reproduce in one known case: when a plugin is implicitly enabled (as a dependency). Those plugins won't participate in plugin discovery as for some code paths they are not really enabled.

michaelklishin commented 4 years ago

Some evidence:

rabbitmq-plugins list
Listing plugins with pattern ".*" ...
 Configured: E = explicitly enabled; e = implicitly enabled
 | Status: [failed to contact rabbit@warp10 - status not shown]
 |/
[  ] rabbitmq_amqp1_0                  3.8.3
[  ] rabbitmq_auth_backend_cache       3.8.3
[  ] rabbitmq_auth_backend_http        3.8.3
[  ] rabbitmq_auth_backend_ldap        3.8.3
[  ] rabbitmq_auth_backend_oauth2      3.8.3
[  ] rabbitmq_auth_mechanism_ssl       3.8.3
[  ] rabbitmq_consistent_hash_exchange 3.8.3
[  ] rabbitmq_event_exchange           3.8.3
[e ] rabbitmq_federation               3.8.3
[E ] rabbitmq_federation_management    3.8.3
[  ] rabbitmq_jms_topic_exchange       3.8.3
[e ] rabbitmq_management               3.8.3
[e ] rabbitmq_management_agent         3.8.3
[  ] rabbitmq_mqtt                     3.8.3
[  ] rabbitmq_peer_discovery_aws       3.8.3
[  ] rabbitmq_peer_discovery_common    3.8.3
[  ] rabbitmq_peer_discovery_consul    3.8.3
[  ] rabbitmq_peer_discovery_etcd      3.8.3
[  ] rabbitmq_peer_discovery_k8s       3.8.3
[  ] rabbitmq_prometheus               3.8.3
[  ] rabbitmq_random_exchange          3.8.3
[  ] rabbitmq_recent_history_exchange  3.8.3
[  ] rabbitmq_sharding                 3.8.3
[E ] rabbitmq_shovel                   3.8.3
[  ] rabbitmq_shovel_management        3.8.3
[  ] rabbitmq_stomp                    3.8.3
[  ] rabbitmq_top                      3.8.3
[  ] rabbitmq_tracing                  3.8.3
[  ] rabbitmq_trust_store              3.8.3
[e ] rabbitmq_web_dispatch             3.8.3
[  ] rabbitmq_web_mqtt                 3.8.3
[  ] rabbitmq_web_mqtt_examples        3.8.3
[  ] rabbitmq_web_stomp                3.8.3
[  ] rabbitmq_web_stomp_examples       3.8.3

and rabbitmqctl help includes

Shovel plugin:

   delete_shovel                 Deletes a Shovel
   restart_shovel                Restarts a dynamic Shovel
   shovel_status                 Displays status of Shovel on a node

Use 'rabbitmqctl help <command>' to learn more about a specific command
michaelklishin commented 4 years ago

One scenario in which I can reproduce this:

CLI tools entirely depend on rabbit_plugins in discovering what plugins are enabled and should be placed on the code path.

I cannot reproduce any other way when the plugin that provides the command is enabled explicitly (not as a dependency of another plugin).

michaelklishin commented 4 years ago

RabbitMQ.CLI.Core.CodePath is where most of the relevant functions reside, e.g. https://github.com/rabbitmq/rabbitmq-cli/blob/master/lib/rabbitmq/cli/core/code_path.ex#L19.

lukebakken commented 4 years ago

OK, yes this is due to the plugin being enabled implicitly. It's pretty confusing behavior but I suspect most people enable both rabbitmq_shovel and rabbitmq_shovel_management at the same time. We can close this until someone else gets tripped up by it 😄