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

CLI commands do not scan [for commands] plugins that are transient dependencies #6020

Closed
Gsantomaggio opened this issue Oct 5, 2022 · 3 comments · Fixed by #6316
Closed
Labels
Milestone

Comments

@Gsantomaggio
Copy link
Member

The command fails in two different contexts.

New installation

  • execute a docker image
docker run -it --name rmq311 --rm \
                 -p 5672:5672 -p 15672:15672 \
                rabbitmq:3.11-management
  • enter to the docker image:
docker exec -it rmq311      /bin/bash
  • enable the plugin in this way:
rabbitmq-plugins enable rabbitmq_stream_management
  • try to execute the command:
rabbitmq-streams add_super_stream invoices --partitions 3

Command 'add_super_stream' not found.

It works only if the rabbitmq_stream plugin is enabled first and then it is possible to enable rabbitmq_stream_management

Update cluster

I had a similar problem during a cluster update from 3.10.7 to 3.11
I tried to execute:

rabbitmq-streams add_super_stream test --partitions 3

Command 'add_super_stream' not found.

I had to remove and enable the plugin to make it working:

### disable the plugin
root@node0:~> rabbitmq-plugins disable rabbitmq_stream
Disabling plugins on node rabbit@node0:
rabbitmq_stream
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_top
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@node0...
The following plugins have been disabled:
  rabbitmq_stream
  rabbitmq_stream_management

stopped 2 plugins.

### enable  it again
root@node0:~> rabbitmq-plugins enable  rabbitmq_stream
Enabling plugins on node rabbit@node0:
rabbitmq_stream
The following plugins have been configured:
  rabbitmq_management
  rabbitmq_management_agent
  rabbitmq_stream
  rabbitmq_top
  rabbitmq_web_dispatch
Applying plugin configuration to rabbit@node0...
The following plugins have been enabled:
  rabbitmq_stream

started 1 plugins.

### it works here 
root@node0:~> rabbitmq-streams add_super_stream test --partitions 3
Adding a super stream...
Super stream test has been created
@Gsantomaggio
Copy link
Member Author

Gsantomaggio commented Oct 6, 2022

how to reproduce

$ bazel run broker RABBITMQ_ENABLED_PLUGINS=rabbitmq_stream_management

then

$ ./bazel-bin/broker-home/sbin/rabbitmq-streams add_super_stream test --partitions 3

Command 'add_super_stream' not found.

Problem

The Cli uses the enabled_plugins file to understand the plugin commands through implements_command_behaviour

defp make_module_map(modules, scope) when modules != nil do
commands_ns = Regex.recompile!(@commands_ns)
modules
|> Enum.filter(fn mod ->
to_string(mod) =~ commands_ns and
module_exists?(mod) and
implements_command_behaviour?(mod) and
command_in_scope(mod, scope)
end)
|> Enum.map(&command_tuple/1)
|> Map.new()
end

When the stream is enabled using rabbitmq-plugin enable rabbitmq_stream_management inside the enabled_plugins there is only [rabbitmq_stream_management].

That's why the rabbitmq_stream commands are not loaded.

This error also happens with rabbitmq_shovel_management and rabbitmq_federation_management

@Gsantomaggio Gsantomaggio changed the title "Super stream Add" command fails when the plugins are not enabled in sequence Cli commands fail when the plugins are transient Oct 6, 2022
@Gsantomaggio Gsantomaggio added bug and removed streams labels Oct 6, 2022
@Gsantomaggio
Copy link
Member Author

One of the possible solutions could be:

  • query the node to ask the actual running plugins
  • fall back to the file if the node is down

It could be a change without too much impact

per conversation with @dumbbell

@SimonUnge
Copy link
Collaborator

Started looking into this issue, with a solution that does not require communication with a running node (via RPC), but instead include a plugins dependencies in the verification.

@michaelklishin michaelklishin changed the title Cli commands fail when the plugins are transient CLI commands do not scan [for commands] plugins that are transient dependencies Oct 28, 2022
@michaelklishin michaelklishin added this to the 3.11.3 milestone Nov 1, 2022
michaelklishin added a commit that referenced this issue Nov 2, 2022
In many tests, we do not care what is the complete set of plugins
running on a node (or present, or in a specific state). We only
care that a few select ones are running, are of the expected version,
in a certain state, and so on.

So list comparison assertions are counterproductive and lead to
test interference that is difficult to track down. In many cases
we can do more fine grained assertions and ignore the rest of
the plugins present on the node.

References #6289, #6020.
michaelklishin added a commit that referenced this issue Nov 3, 2022
As of #6316/#6020 all plugin directories are scanned earlier and
unconditionally. This means that a path must be set or CLI
tools won't be functional.
michaelklishin added a commit that referenced this issue Nov 3, 2022
As of #6316/#6020 all plugin directories are scanned earlier and
unconditionally. In some environments, the path won't be set or
will be set incorrectly. Make sure that 'rabbitmqctl help'
and friends work in such environments, even if no commands from
plugins would be available.

Per discussion with @pjk25.
mergify bot pushed a commit that referenced this issue Nov 3, 2022
In many tests, we do not care what is the complete set of plugins
running on a node (or present, or in a specific state). We only
care that a few select ones are running, are of the expected version,
in a certain state, and so on.

So list comparison assertions are counterproductive and lead to
test interference that is difficult to track down. In many cases
we can do more fine grained assertions and ignore the rest of
the plugins present on the node.

References #6289, #6020.

(cherry picked from commit 6ebbfaa)
mergify bot pushed a commit that referenced this issue Nov 3, 2022
As of #6316/#6020 all plugin directories are scanned earlier and
unconditionally. This means that a path must be set or CLI
tools won't be functional.

(cherry picked from commit c2f87ad)
mergify bot pushed a commit that referenced this issue Nov 3, 2022
As of #6316/#6020 all plugin directories are scanned earlier and
unconditionally. In some environments, the path won't be set or
will be set incorrectly. Make sure that 'rabbitmqctl help'
and friends work in such environments, even if no commands from
plugins would be available.

Per discussion with @pjk25.

(cherry picked from commit 0c821de)
mergify bot pushed a commit that referenced this issue Nov 3, 2022
In many tests, we do not care what is the complete set of plugins
running on a node (or present, or in a specific state). We only
care that a few select ones are running, are of the expected version,
in a certain state, and so on.

So list comparison assertions are counterproductive and lead to
test interference that is difficult to track down. In many cases
we can do more fine grained assertions and ignore the rest of
the plugins present on the node.

References #6289, #6020.

(cherry picked from commit 6ebbfaa)
(cherry picked from commit 65d1c45)
mergify bot pushed a commit that referenced this issue Nov 3, 2022
As of #6316/#6020 all plugin directories are scanned earlier and
unconditionally. This means that a path must be set or CLI
tools won't be functional.

(cherry picked from commit c2f87ad)
(cherry picked from commit afbe032)
mergify bot pushed a commit that referenced this issue Nov 3, 2022
As of #6316/#6020 all plugin directories are scanned earlier and
unconditionally. In some environments, the path won't be set or
will be set incorrectly. Make sure that 'rabbitmqctl help'
and friends work in such environments, even if no commands from
plugins would be available.

Per discussion with @pjk25.

(cherry picked from commit 0c821de)
(cherry picked from commit 9c80895)
mergify bot pushed a commit that referenced this issue Nov 3, 2022
In many tests, we do not care what is the complete set of plugins
running on a node (or present, or in a specific state). We only
care that a few select ones are running, are of the expected version,
in a certain state, and so on.

So list comparison assertions are counterproductive and lead to
test interference that is difficult to track down. In many cases
we can do more fine grained assertions and ignore the rest of
the plugins present on the node.

References #6289, #6020.

(cherry picked from commit 6ebbfaa)
(cherry picked from commit 65d1c45)
(cherry picked from commit cd23499)
mergify bot pushed a commit that referenced this issue Nov 3, 2022
As of #6316/#6020 all plugin directories are scanned earlier and
unconditionally. This means that a path must be set or CLI
tools won't be functional.

(cherry picked from commit c2f87ad)
(cherry picked from commit afbe032)
(cherry picked from commit 78c4b16)
mergify bot pushed a commit that referenced this issue Nov 3, 2022
As of #6316/#6020 all plugin directories are scanned earlier and
unconditionally. In some environments, the path won't be set or
will be set incorrectly. Make sure that 'rabbitmqctl help'
and friends work in such environments, even if no commands from
plugins would be available.

Per discussion with @pjk25.

(cherry picked from commit 0c821de)
(cherry picked from commit 9c80895)
(cherry picked from commit a796343)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
3 participants