Commit Graph

1414 Commits

Author SHA1 Message Date
Michael Klishin 1b642353ca
Update (c) according to [1]
1. https://investors.broadcom.com/news-releases/news-release-details/broadcom-and-vmware-intend-close-transaction-november-22-2023
2023-11-21 23:18:22 -05:00
Michal Kuratczyk 5459975c5c
Revert "Use rabbit_json in the CLI"
This reverts commit 6c65715875.
2023-11-17 13:05:38 +01:00
Michal Kuratczyk 6c65715875
Use rabbit_json in the CLI
dep_json doesn't seem to be maintained
and it's unnecessary anyway, since we can
use rabbit_json, which uses thoas
2023-11-16 00:01:14 +01:00
Michael Klishin 229a9fb7bd
list_policies_that_match: correctly format 'not found' errors as JSON 2023-11-13 21:35:48 -05:00
Michael Klishin 1ff5f6077b
mix format 2023-11-13 21:18:27 -05:00
Michael Klishin fd0488516b
diagnostics list_policies_that_match: support JSON formatting 2023-11-13 20:46:06 -05:00
Michael Klishin c4db560e0e
CLI: mix format 2023-11-13 11:21:29 -05:00
Michal Kuratczyk 408c33ec49
Add list_policies_that_match command 2023-11-13 13:47:54 +01:00
Michael Klishin a88c22144d CLI: mix format 2023-11-06 23:03:41 -05:00
Michael Klishin 114f9b90c9 CLI: refactor 'diagnostics check_if_any_deprecated_features_are_used' 2023-11-06 22:50:35 -05:00
Diana Parra Corbacho 51783e9464 CLI: check if any deprecated features are used returns just the list of features 2023-11-06 17:45:11 +01:00
Michael Klishin cbe2756cbd CLI: tests and refactoring for 'diagnostics check_if_cluster_has_classic_queue_mirroring_policy' 2023-11-06 07:20:08 -05:00
Michael Klishin 827b495d1a CLI: wording 2023-11-06 07:20:08 -05:00
Michael Klishin b725bba735 CLI: add a test for 'ctl remove_classic_queue_mirroring_from_policies' 2023-11-06 07:20:08 -05:00
Diana Parra Corbacho 6288e9aa2c CTL: check if any deprecated features are used command 2023-11-06 07:20:08 -05:00
Diana Parra Corbacho 13e88ced92 Use Diagnostics group 2023-11-06 07:20:08 -05:00
Michael Klishin ae934d9ebc CLI: mix format 2023-11-06 07:20:08 -05:00
Diana Parra Corbacho 70c97be06c CLI: command to remove all classic queue mirroring policies 2023-11-06 07:20:08 -05:00
Diana Parra Corbacho a06698d43d CLI: command to check if cluster has a classic queue mirroring policy 2023-11-06 07:20:08 -05:00
Diana Parra Corbacho 8df94cc13c CLI: commands to list policies / operator policies with CMQ
rabbitmq-queues list_operator_policies_with_classic_queue_mirroring
rabbitmq-queues list_policies_with_classic_queue_mirroring
2023-11-06 07:20:08 -05:00
Jean-Sébastien Pédron b15eb0ff1b
rabbit_db: `join/2` now takes care of stopping/starting RabbitMQ
[Why]
Up until now, a user had to run the following three commands to expand a
cluster:
1. stop_app
2. join_cluster
3. start_app

Stopping and starting the `rabbit` application and taking care of the
underlying Mnesia application could be handled by `join_cluster`
directly.

[How]
After the call to `can_join/1` and before proceeding with the actual
join, the code remembers the state of `rabbit`, the Feature flags
controler and Mnesia.

After the join, it restarts whatever needs to be restarted to. It does
so regardless of the success or failure of the join. One exception is
when the node switched from Mnesia to Khepri as part of that join. In
this case, Mnesia is left stopped.
2023-10-26 11:22:47 +02:00
Michael Klishin 6d3f008336
CLI: mix format 2023-10-10 09:24:29 -04:00
Michael Klishin 17fded2e12
CLI: support for pre-hashed passwords
Providing a pre-hashed and salted password is
not significantly more secure but satisfies those
who cannot pass clear text passwords on the command
line for regulatory reasons.

Note that the optimal way of seeding users is still
definition import on node boot, not scripting with
CLI tools.

Closes #9166
2023-10-09 23:52:34 -04:00
Michael Klishin 856f56ea0b
ctl: add support for providing pre-hashed passwords (WIP) 2023-10-09 23:52:34 -04:00
Alex Valiushko 4df3080fa1 New quorum queue members join as temporary non-voters
Because both `add_member` and `grow` default to Membership status `promotable`,
new members will have to catch up before they are considered cluster members.
This can be overridden with either `voter` or (permanent `non_voter` statuses.
The latter one is useless without additional tooling so kept undocumented.

- non-voters do not affect quorum size for election purposes
- `observer_cli` reports their status with lowercase 'f'
- `rabbitmq-queues check_if_node_is_quorum_critical` takes voter status into
account
2023-10-04 11:14:07 -07:00
Diana Parra Corbacho 5f0981c5a3
Allow to use Khepri database to store metadata instead of Mnesia
[Why]

Mnesia is a very powerful and convenient tool for Erlang applications:
it is a persistent disc-based database, it handles replication accross
multiple Erlang nodes and it is available out-of-the-box from the
Erlang/OTP distribution. RabbitMQ relies on Mnesia to manage all its
metadata:

* virtual hosts' properties
* intenal users
* queue, exchange and binding declarations (not queues data)
* runtime parameters and policies
* ...

Unfortunately Mnesia makes it difficult to handle network partition and,
as a consequence, the merge conflicts between Erlang nodes once the
network partition is resolved. RabbitMQ provides several partition
handling strategies but they are not bullet-proof. Users still hit
situations where it is a pain to repair a cluster following a network
partition.

[How]

@kjnilsson created Ra [1], a Raft consensus library that RabbitMQ
already uses successfully to implement quorum queues and streams for
instance. Those queues do not suffer from network partitions.

We created Khepri [2], a new persistent and replicated database engine
based on Ra and we want to use it in place of Mnesia in RabbitMQ to
solve the problems with network partitions.

This patch integrates Khepri as an experimental feature. When enabled,
RabbitMQ will store all its metadata in Khepri instead of Mnesia.

This change comes with behavior changes. While Khepri remains disabled,
you should see no changes to the behavior of RabbitMQ. If there are
changes, it is a bug. After Khepri is enabled, there are significant
changes of behavior that you should be aware of.

Because it is based on the Raft consensus algorithm, when there is a
network partition, only the cluster members that are in the partition
with at least `(Number of nodes in the cluster ÷ 2) + 1` number of nodes
can "make progress". In other words, only those nodes may write to the
Khepri database and read from the database and expect a consistent
result.

For instance in a cluster of 5 RabbitMQ nodes:
* If there are two partitions, one with 3 nodes, one with 2 nodes, only
  the group of 3 nodes will be able to write to the database.
* If there are three partitions, two with 2 nodes, one with 1 node, none
  of the group can write to the database.

Because the Khepri database will be used for all kind of metadata, it
means that RabbitMQ nodes that can't write to the database will be
unable to perform some operations. A list of operations and what to
expect is documented in the associated pull request and the RabbitMQ
website.

This requirement from Raft also affects the startup of RabbitMQ nodes in
a cluster. Indeed, at least a quorum number of nodes must be started at
once to allow nodes to become ready.

To enable Khepri, you need to enable the `khepri_db` feature flag:

    rabbitmqctl enable_feature_flag khepri_db

When the `khepri_db` feature flag is enabled, the migration code
performs the following two tasks:
1. It synchronizes the Khepri cluster membership from the Mnesia
   cluster. It uses `mnesia_to_khepri:sync_cluster_membership/1` from
   the `khepri_mnesia_migration` application [3].
2. It copies data from relevant Mnesia tables to Khepri, doing some
   conversion if necessary on the way. Again, it uses
   `mnesia_to_khepri:copy_tables/4` from `khepri_mnesia_migration` to do
   it.

This can be performed on a running standalone RabbitMQ node or cluster.
Data will be migrated from Mnesia to Khepri without any service
interruption. Note that during the migration, the performance may
decrease and the memory footprint may go up.

Because this feature flag is considered experimental, it is not enabled
by default even on a brand new RabbitMQ deployment.

More about the implementation details below:

In the past months, all accesses to Mnesia were isolated in a collection
of `rabbit_db*` modules. This is where the integration of Khepri mostly
takes place: we use a function called `rabbit_khepri:handle_fallback/1`
which selects the database and perform the query or the transaction.
Here is an example from `rabbit_db_vhost`:

* Up until RabbitMQ 3.12.x:

        get(VHostName) when is_binary(VHostName) ->
            get_in_mnesia(VHostName).

* Starting with RabbitMQ 3.13.0:

        get(VHostName) when is_binary(VHostName) ->
            rabbit_khepri:handle_fallback(
              #{mnesia => fun() -> get_in_mnesia(VHostName) end,
                khepri => fun() -> get_in_khepri(VHostName) end}).

This `rabbit_khepri:handle_fallback/1` function relies on two things:
1. the fact that the `khepri_db` feature flag is enabled, in which case
   it always executes the Khepri-based variant.
4. the ability or not to read and write to Mnesia tables otherwise.

Before the feature flag is enabled, or during the migration, the
function will try to execute the Mnesia-based variant. If it succeeds,
then it returns the result. If it fails because one or more Mnesia
tables can't be used, it restarts from scratch: it means the feature
flag is being enabled and depending on the outcome, either the
Mnesia-based variant will succeed (the feature flag couldn't be enabled)
or the feature flag will be marked as enabled and it will call the
Khepri-based variant. The meat of this function really lives in the
`khepri_mnesia_migration` application [3] and
`rabbit_khepri:handle_fallback/1` is a wrapper on top of it that knows
about the feature flag.

However, some calls to the database do not depend on the existence of
Mnesia tables, such as functions where we need to learn about the
members of a cluster. For those, we can't rely on exceptions from
Mnesia. Therefore, we just look at the state of the feature flag to
determine which database to use. There are two situations though:

* Sometimes, we need the feature flag state query to block because the
  function interested in it can't return a valid answer during the
  migration. Here is an example:

        case rabbit_khepri:is_enabled(RemoteNode) of
            true  -> can_join_using_khepri(RemoteNode);
            false -> can_join_using_mnesia(RemoteNode)
        end

* Sometimes, we need the feature flag state query to NOT block (for
  instance because it would cause a deadlock). Here is an example:

        case rabbit_khepri:get_feature_state() of
            enabled -> members_using_khepri();
            _       -> members_using_mnesia()
        end

Direct accesses to Mnesia still exists. They are limited to code that is
specific to Mnesia such as classic queue mirroring or network partitions
handling strategies.

Now, to discover the Mnesia tables to migrate and how to migrate them,
we use an Erlang module attribute called
`rabbit_mnesia_tables_to_khepri_db` which indicates a list of Mnesia
tables and an associated converter module. Here is an example in the
`rabbitmq_recent_history_exchange` plugin:

    -rabbit_mnesia_tables_to_khepri_db(
       [{?RH_TABLE, rabbit_db_rh_exchange_m2k_converter}]).

The converter module  — `rabbit_db_rh_exchange_m2k_converter` in this
example  — is is fact a "sub" converter module called but
`rabbit_db_m2k_converter`. See the documentation of a `mnesia_to_khepri`
converter module to learn more about these modules.

[1] https://github.com/rabbitmq/ra
[2] https://github.com/rabbitmq/khepri
[3] https://github.com/rabbitmq/khepri_mnesia_migration

See #7206.

Co-authored-by: Jean-Sébastien Pédron <jean-sebastien@rabbitmq.com>
Co-authored-by: Diana Parra Corbacho <dparracorbac@vmware.com>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2023-09-29 16:00:11 +02:00
Diana Parra Corbacho c241b36bf7 CLI forget_cluster_node: shrink stream queues 2023-09-18 16:08:40 +02:00
Diana Parra Corbacho 7540ccc628 forget_cluster_node: handle errors while shrinking quorum queues 2023-09-15 13:34:53 +02:00
Ayanda-D 1d163886fd new rabbit_amqqueue_control for queue related control operations and fix bazel issues raised in MK's review 2023-09-11 14:13:03 +01:00
Ayanda-D 7daaee8da0 formatting 2023-09-11 14:13:03 +01:00
Ayanda-D 84e924b854 update ctl delete_queue command to use delete_with api 2023-09-11 14:13:02 +01:00
Jean-Sébastien Pédron b8b4b5d187
rabbitmq_cli: Handle absence of the `rabbit_db*` modules in older versions 2023-09-04 21:09:11 +02:00
Jean-Sébastien Pédron b9b4f8a4c1
rabbit_db: Fall back to `rabbit_mnesia` if functions are undefined in remote nodes
[Why]
The CLI may be used against a remote node running a different version.
We took that into account in several uses of the `rabbit_db*` modules on
remote nodes, but not everywhere. Likewise in the
`clustering_management_SUITE` testsuite.

[How]
This patch falls back to previous `rabbit_mnesia`-based calls if the
initial calls throws an `undef` exception.
2023-07-20 15:47:40 +02:00
Michael Klishin 84d6908c29
CLI: squash a Dialyzer warning
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2023-07-19 21:51:36 +04:00
Michael Klishin 449ab048e6
CLI: squash a Dialyzer warning
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2023-07-19 21:51:27 +04:00
Michael Klishin bd3b44aab9
CLI: set OTP logger log level to 'error'
References #8912
2023-07-19 20:25:54 +04:00
Jean-Sébastien Pédron 95449bd20e
rabbit_db_cluster: Check `rabbit` is stopped in `forget_node()`
[Why]
`rabbit_mnesia` indirectly checks that `rabbit` is stopped on the remote
node because `mnesia:del_table_copy()` requires that Mnesia is stopped
to delete the schema. However, this is not specific to Mnesia and we
want `rabbit` to be stopped when we use Khepri in the future.

[How]
We use `rabbit:is_running(Node)` to query the status of RabbitMQ on the
remote node to forget. This is not atomic so there is a small chance
that RabbitMQ is restarted between the check and the actual forget.

Note: `rabbit_mnesia` also removes some queues and emit a "left cluster"
event after a successful forget. However, this part was not moved
because other parts of the module rely on this in RPC calls. To keep
nodes compatibles, the calls are left in place. They will be duplicated
for Khepri.
2023-07-11 16:46:27 +02:00
Michael Klishin e9e4be7ae9
mix format on Elixir 1.15 2023-07-08 18:46:04 +04:00
Michael Klishin 1a8c5c0e49
mix format 2023-07-08 06:32:32 +04:00
Michael Davis 5f3baf381d
CLI: Rename disk space monitoring commands 2023-07-07 11:16:19 -05:00
Rin Kuryloski 59f5494df2 elixir syntax over erlang 2023-07-04 17:45:50 +02:00
Rin Kuryloski 89a3ffcff2 Improve loading of public_key in listeners.ex
Inspired by https://github.com/voltone/x509/pull/60/files
2023-07-04 17:45:32 +02:00
Rin Kuryloski 42d29a5ca3 Run 'mix format' with elixir 1.15.2 2023-07-04 17:45:32 +02:00
Rin Kuryloski 8efc71eb9f Fix rabbitmqctl compilation under elixir 1.15.x 2023-07-04 17:45:04 +02:00
Michael Klishin e1a1984293
CLI tools: introduce commands that enable and disable free disk space monitoring (#8743)
* Closes #8741

References #8740

---------

Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
2023-07-04 00:14:01 +04:00
Michael Klishin bffc5d519c
Correct a couple of typos 2023-05-02 16:48:14 +04:00
Michael Klishin c9221bd717
Improve rabbitmq-queues {add,delete}_member error messages
when target queue was not found.
2023-05-02 13:28:29 +04:00
Michael Klishin d5f16d4ce6
mix format 2023-05-02 13:08:31 +04:00
Michael Klishin e8cb0c4947
rabbitmq-queues add_member: improve error reporting 2023-05-02 12:14:48 +04:00
Michael Klishin 29d17f05cd
rabbitmq-queues add_member: extract the correct argument
during execution environment validation.
2023-05-02 12:14:26 +04:00
Michael Klishin 247452de5d
rabbitmq-queues add_member: add a missing import 2023-05-02 11:08:00 +04:00
Michael Klishin d4a2d48cea
rabbitmq-queues: validate cluster membership of the argument
Specifically of the node where new replicas should be
placed.

Closes #8007
2023-05-02 10:55:31 +04:00
Michael Klishin 26ebd5c061
Merge pull request #7970 from rabbitmq/mk-silence-remote-shell-dialyzer-on-otp-26
CLI: more OTP 26 compatibility for remote_shell
2023-04-24 21:44:51 +04:00
Michael Klishin 57cd750a1a mix format 2023-04-24 21:16:41 +04:00
Michael Klishin 4e41246415 CLI: more OTP 26 compatibility for remote_shell
shell:start_interactive/1 takes a {node(), mfa()}, not
{node(), atom(), atom(), non_neg_integer()}
2023-04-24 20:54:13 +04:00
Michael Klishin ddf7926941 CLI: make input ordering preditable when formatting a table
if the input is given as a map.

References #7931, #7921
2023-04-24 14:50:31 +04:00
Michael Klishin cec151df59
Introduce a way to update virtual host metadata using CLI tools (#7914)
Introduce 'ctl update_vhost_metadata'

that can be used to update the description, tags or default queue type of
any existing virtual hosts.

Closes #7912, #7857.

#7912 will need an HTTP API counterpart change.
2023-04-18 02:54:37 +04:00
Michael Klishin f1a922a17c Virtual host limit: error type naming
vhost_precondition_failed => vhost_limit_exceeded

vhost_limit_exceeded is the error type used by
definition import when a per-vhost is exceeded.
It feels appropriate for this case, too.
2023-04-01 23:11:48 +04:00
Simon Unge 574ca55a3f See #7777. Use vhost_max to stop vhost creation in rabbitmq 2023-03-31 12:18:16 -07:00
Rin Kuryloski 0be0b7f82d
Merge pull request #7692 from rabbitmq/rin/rabbitmq-cli-branch-switching
fix up bazel build of rabbitmq_cli when branch switching
2023-03-30 08:46:49 +02:00
Michael Klishin 2b1a80f1e9
Merge pull request #7717 from rabbitmq/rabbitmq-server-7716
CLI: correctly override DocGuide.virtual_hosts path segment
2023-03-22 10:32:28 +04:00
Michael Klishin 4741b7a6f7 CLI: define a couple more doc guides 2023-03-22 10:31:55 +04:00
Michael Klishin 94cae1d3ed CLI: correctly override DocGuide.virtual_hosts path segment
Closes #7716
2023-03-22 10:21:04 +04:00
Rin Kuryloski 5d27b3c246 Fix a compiler warning in the cli 2023-03-21 15:24:27 +01:00
markus812498 e676ab7067 added :streams to the help command scopes 2023-03-09 15:01:05 +13:00
Loïc Hoguin 74ce1a4bcc
Fix rabbitmq-diagnostics remote_shell for 26.0 (#7441) 2023-02-27 15:27:32 +01:00
Luke Bakken f420487e5e
Add documentation for hashing passwords
Fixes #7432

Adds HTTP API documentation as well as `rabbitmqctl hash_password` docs.

Add `rabbitmqctl` docs
2023-02-26 15:16:38 -08:00
Luke Bakken d9d6e1bef6
Move rabbit_password to rabbit_common
This allows `rabbitmqctl hash_password` to run without having RabbitMQ up.

Follow-up to:
* #5957
* #7003
2023-02-25 09:53:46 -08:00
Luke Bakken b0d2f94eed
Remove RABBITMQ_ERLANG_COOKIE warning
Fixes #7262
2023-02-22 13:09:01 -08:00
Jean-Sébastien Pédron 42bcd94dce
rabbit_db_cluster: New module on top of databases clustering
This new module sits on top of `rabbit_mnesia` and provide an API with
all cluster-related functions.

`rabbit_mnesia` should be called directly inside Mnesia-specific code
only, `rabbit_mnesia_rename` or classic mirrored queues for instance.
Otherwise, `rabbit_db_cluster` must be used.

Several modules, in particular in `rabbitmq_cli`, continue to call
`rabbit_mnesia` as a fallback option if the `rabbit_db_cluster` module
unavailable. This will be the case when the CLI will interact with an
older RabbitMQ version.

This will help with the introduction of a new database backend.
2023-02-22 15:28:04 +01:00
Rin Kuryloski 609171ec70 Rename the tanzu cli scope to vmware
And update other references to commercial editions
2023-02-16 13:49:54 +01:00
Michael Klishin d0dc951343
Merge pull request #7058 from rabbitmq/add-node-lists-functions-to-clarify-intent
rabbit_nodes: Add list functions to clarify which nodes we are interested in
2023-02-13 23:06:50 -03:00
David Ansari 575f4e78bc Remove compatibility for feature flag stream_queue
Remove compatibility code for feature flag `stream_queue`
because this feature flag is required in 3.12.

See #7219
2023-02-13 15:31:40 +00:00
Jean-Sébastien Pédron d65637190a
rabbit_nodes: Add list functions to clarify which nodes we are interested in
So far, we had the following functions to list nodes in a RabbitMQ
cluster:
* `rabbit_mnesia:cluster_nodes/1` to get members of the Mnesia cluster;
  the argument was used to select members (all members or only those
  running Mnesia and participating in the cluster)
* `rabbit_nodes:all/0` to get all members of the Mnesia cluster
* `rabbit_nodes:all_running/0` to get all members who currently run
  Mnesia

Basically:
* `rabbit_nodes:all/0` calls `rabbit_mnesia:cluster_nodes(all)`
* `rabbit_nodes:all_running/0` calls `rabbit_mnesia:cluster_nodes(running)`

We also have:
* `rabbit_node_monitor:alive_nodes/1` which filters the given list of
  nodes to only select those currently running Mnesia
* `rabbit_node_monitor:alive_rabbit_nodes/1` which filters the given
  list of nodes to only select those currently running RabbitMQ

Most of the code uses `rabbit_mnesia:cluster_nodes/1` or the
`rabbit_nodes:all*/0` functions. `rabbit_mnesia:cluster_nodes(running)`
or `rabbit_nodes:all_running/0` is often used as a close approximation
of "all cluster members running RabbitMQ". This list might be incorrect
in times where a node is joining the clustered or is being worked on
(i.e. Mnesia is running but not RabbitMQ).

With Khepri, there won't be the same possible approximation because we
will try to keep Khepri/Ra running even if RabbitMQ is stopped to
expand/shrink the cluster.

So in order to clarify what we want when we query a list of nodes, this
patch introduces the following functions:
* `rabbit_nodes:list_members/0` to get all cluster members, regardless
  of their state
* `rabbit_nodes:list_reachable/0` to get all cluster members we can
  reach using Erlang distribution, regardless of the state of RabbitMQ
* `rabbit_nodes:list_running/0` to get all cluster members who run
  RabbitMQ, regardless of the maintenance state
* `rabbit_nodes:list_serving/0` to get all cluster members who run
  RabbitMQ and are accepting clients

In addition to the list functions, there are the corresponding
`rabbit_nodes:is_*(Node)` checks and `rabbit_nodes:filter_*(Nodes)`
filtering functions.

The code is modified to use these new functions. One possible
significant change is that the new list functions will perform RPC calls
to query the nodes' state, unlike `rabbit_mnesia:cluster_nodes(running)`.
2023-02-13 12:58:40 +01:00
Michael Klishin 7b5e8a9955
ctl add_vhost: minor improvements to help output 2023-02-09 15:12:51 -05:00
Michael Klishin ab99ccfa45
Introduce a CLI command that grants permissions to all virtual hosts
Closes #1000
2023-02-06 13:07:09 -05:00
Rin Kuryloski 0ac62a4a3b Forward-port dialyzer related rabbitmq_cli fixes from #7122 2023-02-01 23:21:10 +01:00
Michael Klishin 6fd7b983d8
Merge pull request #7135 from rabbitmq/mk-report-total-core-count-cluster-status
List CPU core count in 'rabbitmq-diagnostics cluster_status'
2023-02-01 06:45:41 -05:00
Michael Klishin 1f902fd016
mix format 2023-01-31 20:57:11 -05:00
Michael Klishin cee705b99f
List CPU core count in 'rabbitmq-diagnostics cluster_status'
Both to simplify troubleshooting in some cases and to make it
easier to spot licensing irregularities.
2023-01-31 20:37:44 -05:00
Michael Klishin 2cf2133a44
Fix one more issue reported by CLI tools Dialyzer
(cherry picked from commit 5d8ba2f32a)
2023-01-31 17:47:24 -05:00
Rin Kuryloski bdb2046185
Add rabbitmq_cli dialyze to bazel (#7066)
* Add rabbitmq_cli dialyze to bazel

and fix a number of warnings

Because we stop mix from recompiling rabbit_common in bazel, many
unknown functions are reported, so this dialyzer analysis is somewhat
incomplete.

* Use erlang dialyzer for rabbitmq_cli rather than mix dialyzer

Since this resolves all of the rabbit functions, there are far fewer
unknown functions.

Requires yet to be released rules_erlang 3.9.2

* Temporarily use pre-release rules_erlang

So that checks can run on this PR without a release

* Fix additional dialyzer warnings in rabbitmq_cli

* rabbitmq_cli: mix format

* Additional fixes for ignored return values

* Revert "Temporarily use pre-release rules_erlang"

This reverts commit c16b5b6815.

* Use rules_erlang 3.9.2
2023-01-31 15:05:52 +01:00
Simon Unge 03617f681c See #5957. Accept empty arg and prompt for password 2023-01-26 11:46:24 -08:00
Alexey Lebedeff a9b44f017c Fix all dialyzer warnings in `rabbitmq_stomp` 2023-01-25 16:13:10 +01:00
Simon Unge 67bc94ed16 See #5957. CLI command to generate hashed password from cleartext password 2023-01-23 14:47:29 -08:00
Rin Kuryloski 08d641a1a9 Fix dialyzer warnings revealed from previous commit 2023-01-19 17:29:29 +01:00
Michael Klishin 9d69a4b325
CLI: mix format 2023-01-16 09:24:37 -08:00
Michael Klishin 226a7603e8
diagnostics check_port_connectivity: support --address
For scenarios where node hostname resolution on the invoking
host is not a suitable option and a particular address
should be tried instead.

Closes #6853.
2023-01-16 09:24:37 -08:00
Alexey Lebedeff 2c4e4fb691 Fix all dialyzer warnings in rabbitmq_stream
There are some elixir-related messages about undefined functions, but
they don't produce warnings (yet).
2023-01-16 17:11:24 +01:00
Rin Kuryloski d3794cf2c0 Conform vhost tags to a list when set with the cli in all cases
`rabbitmqctl add_vhost myvhost --tags "my_tag"` would not previously
conform "my_tag" to a list before setting vhost metadata, which could
cause crashes when the list was read.
2023-01-13 10:06:11 +01:00
Jean-Sébastien Pédron 8bad27b16d
rabbitmq_cli: Fix typo where we set `rabbit`'s `data_dir` environment variable
The application name was incorrect, leading to errors when trying to use
this data dir as part of the `forget_cluster_node` command.
2023-01-12 15:33:31 +01:00
Michael Klishin ec4f1dba7d
(c) year bump: 2022 => 2023 2023-01-01 23:17:36 -05:00
Michal Kuratczyk 4160dac33e
Check if stream coordinator is quorum critial 2022-12-22 10:02:13 +01:00
Arnaud Cogoluègnes d3caa1cdaa
Merge pull request #6440 from rabbitmq/stream-balancing
Streams rebalancing
2022-12-14 16:51:30 +01:00
Arnaud Cogoluègnes 41c6e55c2a
Fix typos 2022-12-13 11:01:35 +01:00
Michael Klishin d339027850
Merge pull request #6598 from rabbitmq/rin/rabbitmqctl-usage-lists-plugin-commands
Make rabbitmqctl with no command (implicit "help") behave more like with "help"
2022-12-09 13:45:17 +04:00
Péter Gömöri 88877c654c Fix error filtering and printing in queue grow/shrink commands 2022-12-08 18:02:31 +01:00
Rin Kuryloski e2d26953b6 mix format 2022-12-08 17:24:50 +01:00
Rin Kuryloski 8696531d8d Apply node name normalization in cli when loading available commands 2022-12-08 17:07:11 +01:00
Rin Kuryloski 27bb51bb1e Also pass remote node info for regular help commands 2022-12-08 17:05:55 +01:00
Rin Kuryloski 1c5f577c19 Make rabbitmqctl with no command behave more like with "help"
For instance, if '-n ...' has been used to specify a node, it will be
used to discover plugins and print additional commands made available
by plugins, as the "help" command does
2022-12-08 15:26:09 +01:00
Alexey Lebedeff 398f072a03 Expose effective policy definition via CLI
Now it's only visible in the management UI.

One can craft a series of calls to `rabbitmqctl list_queues` and
`rabbitmqctl list_policies` to achieve similiar result. But it's more
difficult, and also doesn't take operator policy (if any) into account.
2022-12-02 17:06:17 +01:00
Jean-Sébastien Pédron ae06f79c10
rabbit: Introduce `rabbit:data_dir/0`
This function returns the data directory where all subsystems should
store their files.

Historically, this was the Mnesia directory. But semantically, this
should be the reverse: RabbitMQ owns the data directory and Mnesia is
configured to put its files there too.

`rabbit_mnesia:dir/0` now calls `rabbit:data_dir/0`.

Other subsystems will be modified in a follow-up commit to call
`rabbit:data_dir/0` instead of `rabbit_mnesia:dir/0`.
2022-11-30 14:41:28 +01:00
Jean-Sébastien Pédron 99b14fd0fa
rabbit_env: Rename `mnesia_*dir` to `data_*dir`
The location and name of this directory remains the same for
compatibility reasons. Therefore, it sill contains "mnesia" in its name.
However, semantically, we want this directory to be unrelated to Mnesia.

In the end, many subsystems write files and directories there, including
Mnesia, all Ra systems and in the future, Khepri.
2022-11-30 13:00:49 +01:00
Michal Kuratczyk feff12cbe2
Stream rebalancing support 2022-11-29 18:59:50 +01:00
Karl Nilsson 97c2bb15c6 Stream coordiantor restart stream preferred leader flag
Allow the restart_stream command / API to provide a preferrred leader
hint. If this leader replies to the coordinator stop phase as one of the
first n/2+1 members and has a sufficientl up-to-date stream tail it will be
selected as the leader, else it will fall back and use the modulus logic to
select the next leader.

sufficiently up to
2022-11-29 16:30:44 +00:00
Karl Nilsson 9736425fa5 Add restart_stream command to rabbitmq-streams
Also add epoch to stream_status output which requires osiris 1.4.1
2022-11-29 16:30:41 +00:00
Michal Kuratczyk d8ff99180b
Consider streams when quorum critical check (#6448)
Extended the quorum critical check to also consider streams and their
potential unavailability if the nodes is stopped.
2022-11-23 15:24:26 +01:00
Alex Valiushko d70660dac7 Add inclusive aliases to ctl info keys
Includes generic ability to provide aliases in other commands.
2022-11-11 14:44:05 -08:00
Michael Klishin 0c821ded1a
CLI: do not fail if plugin directory does not exist
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.
2022-11-03 15:44:08 +04:00
Simon Unge 917bf55e19
See Issue 6020. Take plugin dependency into account 2022-11-02 13:08:44 +04:00
Michael Klishin 7dcacf5f52
Merge pull request #6294 from rabbitmq/mk-status-format-when-free-disk-space-cannot-be-computed
ctl status: handle cases when free disk space cannot be computed
2022-11-01 17:16:15 +04:00
Michael Klishin 0cd8dff415
CLI: improve isolation of set_disk_free_limit tests 2022-11-01 16:39:35 +04:00
Michael Klishin ca518b846b
ctl status: handle cases when free disk space cannot be computed 2022-11-01 15:25:05 +04:00
Ayanda Dube 4cbbaad2df mix format rabbitmq_cli 2022-10-02 18:54:11 +01:00
Michael Klishin 53c7ea0661
Merge pull request #5579 from rabbitmq/mk-release-eol-date-warnings
Introduce a concept of release series EOL date
2022-08-28 18:18:46 +04:00
Michael Klishin ead5acc7d6 Squash a few compiler warnings
one revealed a real issue in a CLI command
2022-08-28 18:16:01 +04:00
Michael Klishin fc0de65393 Release series support: wording
"maintenance" is already used by node maintenance mode,
"supported" is also closer to the language used in the docs
2022-08-27 22:12:43 +04:00
Michael Klishin 33b4e6f799 Report version series maintenance status via CLI
as part of 'rabbitmq-diagnostics status'
2022-08-27 21:49:35 +04:00
Michael Klishin 83676fa74b
Validate the feature flag behind user-provided queue type on the server end 2022-08-01 19:04:10 +04:00
Michael Klishin 2c4c51d62d
ctl add_vhost: check if relevant feature flags are enabled 2022-08-01 15:56:35 +04:00
Michael Klishin 1b62cfcca2
add_vhost: help wording 2022-07-26 01:16:36 +04:00
Karl Nilsson 65ca0b4dfd Add default_queue_type to list_vhosts command 2022-07-25 12:34:52 +01:00
Karl Nilsson 51fe7c72af Add a --default-queue-type argument to rabbitmqctl add_vhost 2022-07-25 12:34:51 +01:00
Philip Kuryloski 9dc9b92a94 Fix `rabbitmqctl status` when the disk_free cannot be determined
By adjusting RabbitMQ.CLI.InformationUnit to no longer attempt to
convert non-numeric values
2022-05-25 15:46:33 +02:00
Michael Klishin 2b80ed5c5e
Report crypto library version in 'rabbitmq-diagnostics status'
Just like we do in the node startup banner.

Closes #4799.
2022-05-12 16:19:41 +04:00
Péter Gömöri 542ffeebb5 Clarify documented/allowed log_level arg of rabbitmqctl set_log_level
The `critical` log level is already documented on the website/logging section.
2022-05-11 19:22:28 +02:00
Michael Klishin f76e31ca50
ctl clear_user_limits: add a missing argument back to help 2022-04-28 22:46:39 +04:00
Michal Kuratczyk eecdb54292 Make await_online_synchronized_mirror no-op in single-node clusters
Similar to: https://github.com/rabbitmq/rabbitmq-server/pull/2890/
2022-04-14 11:47:40 +02:00
Michael Klishin c38a3d697d
Bump (c) year 2022-03-21 01:21:56 +04:00
Michael Klishin 5e38602f6d
Cosmetics 2022-03-10 18:57:23 +04:00
Michael Klishin 16bdcee5f4
rabbitmqct {encode, decode}: accept more values via standard input
Per discussion with @lhoguin.

References #4216.
2022-03-10 18:55:12 +04:00
Karl Nilsson 4b193608bb
Merge pull request #3121 from rabbitmq/quorum-queues-v2
QQ: introduce new machine version (2)
2022-03-08 16:19:04 +00:00
David Ansari 56e05af6e3 Fix 'rabbitmqctl list_queues --help' output
Before this commit, the help output showed:

```
...
Arguments and Options

<column>
	must be one of #, aliases, are, arguments, auto_delete,
    consumer_capacity, consumer_utilisation, consumers, disk_reads,
    disk_writes, durable, exclusive, exclusive_consumer_pid,
    exclusive_consumer_tag, head_message_timestamp, leader, members,
    memory, message_bytes, message_bytes_persistent, message_bytes_ram,
    message_bytes_ready, message_bytes_unacknowledged, messages,
    messages_persistent, messages_ram, messages_ready,
    messages_ready_ram, messages_unacknowledged,
    messages_unacknowledged_ram, name, online, owner_pid, pid, policy,
    slave_pids, state, synchronised_slave_pids, these, type
...
```
2022-03-02 19:47:49 +01:00
David Ansari 13a30898cf Delete queue returns number of ready messages
AMQP 0.9.1 spec:

1.7.2.10.1. Parameter queue.delete­ok.message­count (message­count)
Ordinal: 1
Domain: message­coun
Reports the number of messages deleted.

For classic and quorum queues, deleting a queue returns the number of
ready messages.

This does not include unacked (or dead lettered messages).
Make it clear in the CLI output.
2022-02-28 16:28:05 +01:00
Michael Klishin d2b7b8a402
Elixir 1.13 OptionParser no longer supports :atom values
so coerce e.g. node names in our own code.
2022-02-04 19:03:14 +03:00
Michael Klishin e18b75e9a1
Safely fetch skip_if_unchanged from options 2022-01-30 00:12:16 +03:00
Michael Klishin 8d9515c017
Support --skip-if-unchanged for global imports via CLI tools 2022-01-29 00:34:56 +03:00
Michael Klishin 057e033431
Introduce definition hashing during import
as an opt-in feature. The goal is to avoid re-importing the definition
from the definition file/directory/source if we know the content
has not changed. Since this feature won't be appropriate for
every environment (sometimes unconditional reimporting is expected),
the feature is opt-in.

This is still a WIP.
2022-01-28 22:52:00 +03:00
Michael Klishin f7d32d69f8 Introduce a new CLI tool (scope), rabbitmq-tanzu
For Tanzu (commercial) plugins to attach their commands to instead of
polluting rabbitmqctl.

Pair: @pjk25
(cherry picked from commit 6e0f2436fa)
2021-11-30 14:54:09 +00:00
David Ansari 38a6ce9601 Fix link of stream docs 2021-07-26 12:03:06 +02:00
Michael Klishin ef14bf067e
ctl add_vhost: propagate tags if no description is given 2021-07-18 08:28:53 +03:00
Arnaud Cogoluègnes 49a70a0f9f
Handle last_stream_member more gently in CLI 2021-06-04 16:35:46 +02:00
Karl Nilsson 9bcd51c2a5 Correct help text for rabbitmq-queue grow command 2021-05-26 14:20:04 +01:00
Gerhard Lazu f8b4e1e298
Add consumer offset_lag to rabbitmq-stream CLI command & Management
This is an important metric to keep track of and be aware (maybe even
alert on) when consumers fall behind consuming stream messages. While
they should be able to catch up, if they fall behind too much and the
stream gets truncated, they may miss on messages.

This is something that we want to expose via Prometheus metrics as well,
but we've started closer to the core, CLI & Management.

This should be merged as soon as it passes CI, we shouldn't wait on the
Prometheus changes - they can come later.

Pair: @kjnilsson

Signed-off-by: Gerhard Lazu <gerhard@lazu.co.uk>
2021-05-21 13:02:48 +01:00
Michael Klishin 040f8cc912
Replace a few more leftover MPLv1.1 license headers
Most files have been using the MPLv2 headers for months now.
These were detected by the OSL process.
2021-05-19 21:20:47 +03:00
Michael Klishin 36020f1036
Merge pull request #3017 from rabbitmq/mk-vhost-update-tags
Make it possible to update virtual host metadata (specifically tags)
2021-05-01 22:04:38 +03:00
Michael Klishin a5373d71d6
Make it possible to update virtual host tags
Currently they can only be specified at creation time
2021-05-01 21:48:50 +03:00
dcorbacho 2998234f48 Move stream_status command to streams
Keeps the alias to diagnostics and queues
2021-04-30 11:33:05 +02:00
dcorbacho 310a483221 CLI command to for stream details
rabbitmq-queues stream_status [--tracking] <queue>
If the --tracking option is enabled, it returns a table with all offset tracking
for that queue.
2021-04-13 15:29:40 +01:00