Commit Graph

2199 Commits

Author SHA1 Message Date
Karl Nilsson 5266902caf garbage 2024-01-22 15:27:35 +00:00
Diana Parra Corbacho 2171b5abe5 Mix format 2024-01-19 11:22:16 -05:00
Diana Parra Corbacho c9c4574dd0 Update rabbitmqctl tests for rename/update cluster nodes 2024-01-19 11:22:16 -05:00
Michael Klishin 06ca99c3ab Fix CLI tools dialyzer 2024-01-19 11:22:16 -05:00
Michael Klishin b2180a558b Make rabbitmqctl rename_cluster_node's friend, update_cluster_nodes, a no-op 2024-01-19 11:22:16 -05:00
Michael Klishin 1556fec127 Make 'rabbitmqctl rename_cluster_node' a no-op
This makes a command that renames cluster members
a no-op. This command is really complex under
the hood and is fundamentally incompatible
with a few key Raft-based features:

 * Khepri
 * Quorum queues
 * Streams

Because Khepri first ships in RabbitMQ 3.13,
now is the time to effectively eliminate this
command.

It will be permanently removed together with
other deprecated CLI commands in 4.0.

Per discussion with the team.

Closes #10367.
2024-01-19 11:22:16 -05:00
Michael Klishin 79d52b9b5d CLI: mix format 2024-01-16 00:13:41 -05:00
Michael Klishin 48ce1b5ec7 Improve supported information units (Mi, Gi, Ti)
This revisits the information system conversion,
that is, support for suffixes like GiB, GB.

When configuration values like disk_free_limit.absolute,
vm_memory_high_watermark.absolute are set, the value
can contain an information unit (IU) suffix.

We now support several new suffixes and the meaning
a few more changes.

First, the changes:

 * k, K now mean kilobytes and not kibibytes
 * m, M now mean megabytes and not mebibytes
 * g, G now means gigabytes and not gibibytes

This is to match the system used by Kubernetes.
There is no consensus in the industry about how
"k", "m", "g", and similar single letter suffixes
should be treated. Previously it was a power of 2,
now a power of 10 to align with a very popular OSS
project that explicitly documents what suffixes it supports.

Now, the additions:

Finally, the node will now validate these suffixes
at boot time, so an unsupported value will cause
the node to stop with a rabbitmq.conf validation
error.

The message logged will look like this:

````
2024-01-15 22:11:17.829272-05:00 [error] <0.164.0> disk_free_limit.absolute invalid, supported formats: 500MB, 500MiB, 10GB, 10GiB, 2TB, 2TiB, 10000000000
2024-01-15 22:11:17.829376-05:00 [error] <0.164.0> Error preparing configuration in phase validation:
2024-01-15 22:11:17.829387-05:00 [error] <0.164.0>   - disk_free_limit.absolute invalid, supported formats: 500MB, 500MiB, 10GB, 10GiB, 2TB, 2TiB, 10000000000
````

Closes #10310
2024-01-15 22:11:57 -05:00
Ariel Otilibili 09b4be92f6 Removed ASCII escape codes if not enabled; fixes #2634
https://hexdocs.pm/elixir/IO.ANSI.html#format/2
2024-01-10 01:04:12 +01:00
Ariel Otilibili a9e488dbed
Fix for #8557, removed ANSI codes in JSON output
Add missing newline chars
2024-01-09 09:15:14 -08:00
Luke Bakken 3f33dfa227
Add -noinput via `rabbitmq-env`
Follow-up to #10131
2023-12-30 16:27:02 -08:00
Luke Bakken cb28ffc05b
Ensure that elixir escript does not read from stdin
This change ensures that you do not have to redirect `stdin` from
`/dev/null` to use `rabbitmqctl` and related utilities in a `while` /
`read` shell loop.

References:
* https://github.com/lukebakken/vesc-1073/blob/main/delete.bash#L24-L32
* https://github.com/rabbitmq/support-tools/pull/38
2023-12-14 06:13:56 -08:00
Karl Nilsson 972e78b9d3 Avoid some cluster wide calls in cluster_status command. 2023-12-13 09:28:21 +00:00
Diana Parra Corbacho a363737337 CLI: list_deprecated_features command
Lists all or used deprecated features
2023-12-11 12:51:13 +01:00
Michael Klishin 9d94048852 Avoid importing resources without specified virtual host
On boot first and foremost. Log a more helpful message.

 See #10068 for the background.
2023-12-08 02:35:17 -05:00
Jean-Sébastien Pédron 84cede17e1
rabbit_peer_discovery: Rewrite core logic
[Why]
This work started as an effort to add peer discovery support to our
Khepri integration. Indeed, as part of the task to integrate Khepri, we
missed the fact that `rabbit_peer_discovery:maybe_create_cluster/1` was
called from the Mnesia-specific code only. Even though we knew about it
because we hit many issues caused by the fact the `join_cluster` and
peer discovery use different code path to create a cluster.

To add support for Khepri, the first version of this patch was to move
the call to `rabbit_peer_discovery:maybe_create_cluster/1` from
`rabbit_db_cluster` instead of `rabbit_mnesia`. To achieve that, it made
sense to unify the code and simply call `rabbit_db_cluster:join/2`
instead of duplicating the work.

Unfortunately, doing so highlighted another issue: the way the node to
cluster with was selected. Indeed, it could cause situations where
multiple clusters are created instead of one, without resorting to
out-of-band counter-measures, like a 30-second delay added in the
Kubernetes operator (rabbitmq/cluster-operator#1156). This problem was
even more frequent when we tried to unify the code path and call
`join_cluster`.

After several iterations on the patch and even more discussions with the
team, we decided to rewrite the algorithm to make node selection more
robust and still use `rabbit_db_cluster:join/2` to create the cluster.

[How]
This commit is only about the rewrite of the algorithm. Calling peer
discovery from `rabbit_db_cluster` instead of `rabbit_mnesia` (and thus
making peer discovery work with Khepri) will be done in a follow-up
commit.

We wanted the new algorithm to fulfill the following properties:

1. `rabbit_peer_discovery` should provide the ability to re-trigger it
   easily to re-evaluate the cluster. The new public API is
   `rabbit_peer_discovery:sync_desired_cluster/0`.

2. The selection of the node to join should be designed in a way that
   all nodes select the same, regardless of the order in which they
   become available. The adopted solution is to sort the list of
   discovered nodes with the following criterias (in that order):

    1. the size of the cluster a discovered node is part of; sorted from
       bigger to smaller clusters
    2. the start time of a discovered node; sorted from older to younger
       nodes
    3. the name of a discovered node; sorted alphabetically

   The first node in that list will not join anyone and simply proceed
   with its boot process. Other nodes will try to join the first node.

3. To reduce the chance of incorrectly having multiple standalone nodes
   because the discovery backend returned only a single node, we want to
   apply the following constraints to the list of nodes after it is
   filtered and sorted (see property 2 above):

    * The list must contain `node()` (i.e. the node running peer
      discovery itself).
    * If the RabbitMQ's cluster size hint is greater than 1, the list
      must have at least two nodes. The cluster size hint is the maximum
      between the configured target cluster size hint and the number of
      elements in the nodes list returned by the backend.

   If one of the constraint is not met, the entire peer discovery
   process is restarted after a delay.

4. The lock is acquired only to protect the actual join, not the
   discovery step where the backend is queried to get the list of peers.
   With the node selection described above, this will let the first node
   to start without acquiring the lock.

5. The cluster membership views queried as part of the algorithm to sort
   the list of nodes will be used to detect additional clusters or
   standalone nodes that did not cluster correctly. These nodes will be
   asked to re-evaluate peer discovery to increase the chance of forming
   a single cluster.

6. After some delay, peer discovery will be re-evaluated to further
   eliminate the chances of having multiple clusters instead of one.

This commit covers properties from point 1 to point 4. Remaining
properties will be the scope of additional pull requests after this one
works.

If there is a failure at any point during discovery, filtering/sorting,
locking or joining, the entire process is restarted after a delay. This
is configured using the following parameters:
* cluster_formation.discovery_retry_limit
* cluster_formation.discovery_retry_interval

The default parameters were bumped to 30 retries with a delay of 1
second between each.

The locking retries/interval parameters are not used by the new
algorithm anymore.

There are extra minor changes that come with the rewrite:
* The configured backend is cached in a persistent term. The goal is to
  make sure we use the same backend throughout the entire process and
  when we call `maybe_unregister/0` even if the configuration changed
  for whatever reason in between.
* `maybe_register/0` is called from `rabbit_db_cluster` instead of at
  the end of a successful peer discovery process. `rabbit_db_cluster`
  had to call `maybe_register/0` if the node was not virgin anyway. So
  make it simpler and always call it in `rabbit_db_cluster` regardless
  of the state of the node.
* `log_configured_backend/0` is gone. `maybe_init/0` can log the backend
  directly. There is no need to explicitly call another function for
  that.
* Messages are logged using `?LOG_*()` macros instead of the old
  `rabbit_log` module.
2023-12-07 15:51:54 +01:00
Michael Klishin 625edededc
Update tests 2023-11-24 16:09:41 -05:00
Michael Klishin 5caad16366
Make 'ctl node_health_check' a no-op
It's been deprecated over three years ago [1]
(before RabbitMQ 3.9).

1. e01753ed7a
2023-11-23 18:18:25 -05:00
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 32eba980f0
CLI: prune_code_paths: false 2023-11-17 13:09:31 +01:00
Michal Kuratczyk 93bb847798
Revert "Drop JSON from mix.exs #9926 #9932"
This reverts commit 8de8e0c18a.
2023-11-17 13:08:10 +01:00
Michal Kuratczyk db56f662af
Revert "Bazel bits for #9926"
This reverts commit 8d402e75b7.
2023-11-17 13:07:28 +01:00
Michal Kuratczyk 5459975c5c
Revert "Use rabbit_json in the CLI"
This reverts commit 6c65715875.
2023-11-17 13:05:38 +01:00
Michael Klishin 8de8e0c18a
Drop JSON from mix.exs #9926 #9932 2023-11-16 10:05:30 -05:00
Michael Klishin 8d402e75b7
Bazel bits for #9926 2023-11-16 09:46:19 -05: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
Rin Kuryloski d81bfb46c0 Another attempt to fix the missing rabbit_framing.hrl error
when running the cli tests

copies rather than symlinks files into the ERL_LIBS dir when building
the cli
2023-11-15 09:51:05 +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 8a76e903a3
One more test renaming to follow CLI conventions 2023-11-13 20:46:31 -05:00
Michael Klishin fd0488516b
diagnostics list_policies_that_match: support JSON formatting 2023-11-13 20:46:06 -05:00
Michael Klishin 2ebc23ef23
Use a standard CLI test suite file naming convention 2023-11-13 19:51:58 -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
Michal Kuratczyk b2c01e3e8e
Remove dialyxir from bazel 2023-11-10 15:37:11 +01:00
Michal Kuratczyk 1ffae77442
Bump CLI deps, remove dialyxir 2023-11-10 15:31:12 +01:00
Michael Klishin 4e58ad9dad CLI: two more test suites 2023-11-08 16:49:53 -05: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
Jean-Sébastien Pédron f571b86692
rabbit_khepri: Remove Mnesia files after migration
[Why]
When a Khepri-based node joins a Mnesia-based cluster, it is reset and
switches back from Khepri to Mnesia. If there are Mnesia files left in
its data directory, Mnesia will restart with stale/incorrect data and
the operation will fail.

After a migration to Khepri, we need to make sure there is no stale
Mnesia files.

[How]
We use `rabbit_mnesia` to query the Mnesia files and delete them.
2023-10-17 09:38:12 +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 290c1c05a4 add test for ctl delete_queue for a stopped queue 2023-09-11 14:13:03 +01:00
Ayanda-D 7daaee8da0 formatting 2023-09-11 14:13:03 +01:00
Ayanda-D 3ac283d13e use queue resource names for new queue operations (changes the api specs) 2023-09-11 14:13:03 +01:00
Ayanda-D 3502929b9f ctl delete_queue command test case for a crashed queue 2023-09-11 14:13:03 +01:00
Ayanda-D dd900b4c98 fix unrelated typo 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 7b26f44405
list_policies_command_test.exs: Use a non-deprecated policy 2023-09-04 21:09:11 +02: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
cui fliter 76989a7733
remove repetitive words (#8981)
Signed-off-by: cui fliter <imcusg@gmail.com>
2023-07-31 12:50:52 +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
Rin Kuryloski d563992569 Do not force mix format check as part of build
It makes joint 1.14/1.15 elixir compatibility too impractical

the format check is still performed in ci by bazel
2023-07-17 08:25:01 +02: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
Jean-Sébastien Pédron 15f208eed8
rabbit_db_cluster: Move generic clustering steps from `rabbit_mnesia`
[Why]
When a single node or a cluster is initialized, we go through a few
steps which are not Mnesia-specific or even related. For instance, we
verify that both ends are compatible w.r.t. feature flags.

When we will introduce Khepri, we will have to go through the same
generic steps. Therefore, it makes sense to drive those steps from
`rabbit_db_cluster` and only call into `rabbit_mnesia` when needed.

[How]
The generic code is moved from `rabbit_mnesia` to `rabbit_db_cluster`.
2023-07-07 09:42:32 +02:00
Rin Kuryloski 058b5e1a61 Update elixir logger config for 1.15+ 2023-07-04 17:45:50 +02:00
Rin Kuryloski 4abee60c4d Run cli format check on elixir 1.15 only 2023-07-04 17:45:50 +02:00
Rin Kuryloski 59f5494df2 elixir syntax over erlang 2023-07-04 17:45:50 +02:00
Rin Kuryloski 2c5e9a5775 Fix rabbitmq_cli test compilation under elixir 1.15 2023-07-04 17:45:32 +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 98c85f367f Bump (c) year 2023-07-04 00:21:40 +04: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 7e3021ea50 Mix project: version bump 2023-06-21 03:06:17 +04:00
Michael Klishin d3e01675b1 CLI: allow for Elixir 1.15 2023-06-21 03:03:33 +04:00
Michael Klishin 55442aa914 Replace @rabbitmq.com addresses with rabbitmq-core@groups.vmware.com
Don't ask why we have to do it. Because reasons!
2023-06-20 15:40:13 +04:00
Michal Kuratczyk a59c2b5c4f
Bump CSV to 3.0.5 in erlang.mk (#8448)
Overlooked in https://github.com/rabbitmq/rabbitmq-server/pull/8348
2023-06-01 15:11:28 +02:00
GitHub 823b983474 bazel run gazelle 2023-05-27 04:03:48 +00:00
Michal Kuratczyk fb3655610c
Update CSV to 3.0.5;; remove unused dep 2023-05-26 18:04:42 +02:00
GitHub a29b6fd84d bazel run gazelle 2023-05-17 04:02:31 +00:00
GitHub c344240d30 bazel run gazelle 2023-05-13 04:02:10 +00:00
Rin Kuryloski ea895a0023 Account for Elixir containing several core applications
- eex
- elixir
- ex_unit
- iex
- logger
- mix

So that apps (like rabbitmq_cli) can dialyze against the extra
components
2023-05-12 08:26:42 +02:00
Rin Kuryloski 08061144ad Pass csv and json to rabbitmq_cli plt
So that they are no longer reported as unknown in
//deps/rabbitmq_cli:dialyze
2023-05-12 08:26:42 +02:00
Rin Kuryloski 19f4abd55b Build cli deps as .ez archives
This provides an elixir/erlang agnostic way of providing them other
erlang rules
2023-05-12 08:26:42 +02: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
Rin Kuryloski a944439fba Replace globs in bazel with explicit lists of files
As this is preferred in rules_erlang 3.9.14
2023-04-25 17:29:12 +02: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 8625301e8d CLI: drop two table formatter tests
The only way to make them reliable in their current form
would be converting to keyword lists, which are covered anyway.
2023-04-24 19:52:45 +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 c0ed80c625
Merge pull request #6466 from rabbitmq/gazelle
Use gazelle for some maintenance of bazel BUILD files
2023-04-19 09:33:44 +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
Rin Kuryloski 8de8f59d47 Use gazelle generated bazel files
Bazel build files are now maintained primarily with `bazel run
gazelle`. This will analyze and merge changes into the build files as
necessitated by certain code changes (e.g. the introduction of new
modules).

In some cases there hints to gazelle in the build files, such as `#
gazelle:erlang...` or `# keep` comments. xref checks on plugins that
depend on the cli are a good example.
2023-04-17 18:13:18 +02:00
Michael Klishin 0f8a5899de
Merge branch 'main' into otp26-compatibility 2023-04-17 14:23:21 +04:00
Rin Kuryloski 8a7eee6a86 Ignore warnings when building plt files for dependencies
As we don't generally care if a dependency has warnings, only the
target
2023-04-17 10:09:24 +02:00
Michal Kuratczyk e62bef164a
Don't rely on implicit order in CLI tests 2023-04-13 14:37:19 +02:00
Michal Kuratczyk 699af2c8c3
Don't rely on implicit order in a test 2023-04-13 14:37:18 +02:00
Rin Kuryloski 12dea642ef Properly escape certain shell variables in bazel
In places where such files recently changed
2023-04-13 09:45:28 +02:00
Rin Kuryloski 12153ed823 Fetch github.com/hexpm/hex via bzlmod
This fixes a visibility issue when a bazel module depends on
rabbitmq-server
2023-04-13 09:45:28 +02:00
Rin Kuryloski f09b31e8c5
Fetch all cli deps with bazel (#7875)
* Fetch all prod cli deps with bazel

This avoids issues with hex and OTP 26, and is needed for offline
bazel builds anyway

* Fetch test cli deps with bazel

* mix format
2023-04-12 16:27:32 +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
Rin Kuryloski 87fc43df11 Try to make `bazel clean` unnecessary when switching branches
Sometimes switching branches seems to cause an issue with cli
compilation in bazel. This is an attempt to fix that.
2023-03-21 15:23:02 +01:00
Rin Kuryloski 7acfc4ed98
Merge pull request #7619 from rabbitmq/rin/bazel-rabbitmqctl-skip-test-deps
Avoid fetching test deps when building rabbitmqctl with bazel
2023-03-16 10:02:48 +01:00
Michael Klishin aedd6cb6ff
Merge pull request #7620 from markus812498/add-cli-streams-help
added :streams to the help command scopes
2023-03-15 18:57:20 +04:00
Rin Kuryloski 8e7e891589 Avoid fetching test deps when building rabbitmqctl with bazel 2023-03-15 11:54:37 +01:00
Rin Kuryloski eba1d531c9 Fetch cli prod deps via bazel or erlang.mk instead of mix
In preparation for offline bazel builds
2023-03-14 23:11:36 +01:00
Jean-Sébastien Pédron 091d756d97
rabbitmq_cli: Fix invalid feature flag definitions
`desc` was set to binaries instead of strings.
2023-03-10 09:25:42 +01:00
markus812498 e676ab7067 added :streams to the help command scopes 2023-03-09 15:01:05 +13:00
Rin Kuryloski e66e5ed62d Pin rabbitmq_cli non-test deps
- Use the same stdout_formatter copy for both erlang and rabbitmq_cli
- Use the same observer_cli copy for both erlang and rabbitmq_cli
2023-03-01 09:54:35 +01: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
Rin Kuryloski f827490171
Merge pull request #7286 from rabbitmq/rin/add-v3.12.x-references
Add additional v3.12.x references
2023-02-14 18:28:51 +01:00
Rin Kuryloski 93be82d09f Add 3.13.0 as an allowed version in the test plugin in cli tests 2023-02-14 18:11:23 +01:00
Michael Klishin 8ac0829c15
Merge pull request #7196 from rabbitmq/dialyzer-enable-Wunkown
Fix all dependencies for the dialyzer
2023-02-14 13:41:22 -03:00
Michael Klishin 5a8e74ed5d
Merge pull request #7280 from rabbitmq/rin/rabbit_vhost-update_tags-skip-notify-if-unchanged
rabbit_vhost:set_tags/2 avoids notifying if tags are unchanged
2023-02-14 06:46:05 -03: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
Michael Klishin 9beda74d86
Sort tags before comparing them in this test
now that the server sorts and deduplicates them
2023-02-13 22:16:21 -03:00
Alexey Lebedeff 949b53543d Fix all dependencies for the dialyzer
This is the latest commit in the series, it fixes (almost) all the
problems with missing and circular dependencies for typing.

The only 2 unsolved problems are:

- `lg` dependency for `rabbit` - the problem is that it's the only
  dependency that contains NIF. And there is no way to make dialyzer
  ignore it - looks like unknown check is not suppressable by dialyzer
  directives. In the future making `lg` a proper dependency can be a
  good thing anyway.

- some missing elixir function in `rabbitmq_cli` (CSV, JSON and
  logging related).

- `eetcd` dependency for `rabbitmq_peer_discovery_etcd` - this one
  uses sub-directories in `src/`, which confuses dialyzer (or our bazel
  machinery is not able to properly handle it). I've tried the latest
  rules_erlang which flattens directory for .beam files, but it wasn't
  enough for dialyzer - it wasn't able to find core erlang files. This
  is a niche plugin and an unusual dependency, so probably not worth
  investigating further.
2023-02-13 17:37:44 +01: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