Commit Graph

2199 Commits

Author SHA1 Message Date
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
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
Jean-Sébastien Pédron 78e8c595b1
set_permissions_globally_command_test: Fix "invalid_regex patterns" test expectations
Testcases are executed in a random order. Unfortunately, this testcase
depended on side effects of other testcases. If this testcase was
executed first, then there were no permissions set and the testcase
would fail.

It now lists permissions before and after the actual test and compare
both.
2023-02-08 10:21:10 +01:00
Jean-Sébastien Pédron 271a7babdf
set_permissions_globally_command_test: Always set @user
Otherwise the command causes a `function_clause` exception in the broker
because a `nil` atom is passed as the username instead of a binary.
2023-02-08 10:18:24 +01:00
Michael Klishin 69add44ce3
CLI: mix format 2023-02-06 15:54:09 -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
Michael Klishin 3bfba02281
Merge pull request #6919 from rabbitmq/rin/rework-elixir-dialyze
Rework elixir dialyze
2023-01-21 12:11:02 -06:00
Rin Kuryloski 3b2513eb93 Quote vars in shell in deps/rabbitmq_cli/rabbitmqctl.bzl 2023-01-20 15:50:17 +01:00
Rin Kuryloski dd9a8c96f1 Change `alias` to `test_suite` in deps/rabbitmq_cli/BUILD.bazel
bazel test won't work correctly on an alias, apparently:
https://docs.bazel.build/versions/2.2.0/be/general.html#alias

the recommended workaround is to use a test_suite instead
2023-01-19 22:06:56 +01:00
Rin Kuryloski 057f776c8a Fixup docstring 2023-01-19 17:29:29 +01:00
Rin Kuryloski 08d641a1a9 Fix dialyzer warnings revealed from previous commit 2023-01-19 17:29:29 +01:00
Rin Kuryloski b84e746ee9 Rework plt/dialyze for rabbitmqctl and plugins that depend on it
This allows us to stop ignorning undefined callback warnings

When mix compiles rabbitmqctl, it produces a 'consolidated' directory
alongside the 'ebin' dir. Some of the modules in consolidated are
intended to be used instead of those provided by elixir. We now handle
the conflicts properly in the bazel build.
2023-01-19 17:29:23 +01:00
Michael Klishin c3c4665970
Update tests 2023-01-16 09:24:37 -08: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
Jean-Sébastien Pédron 4840ca9f2f
Merge pull request #6866 from rabbitmq/init-db-from-rabbit_db
rabbit_db: Add `init/0`, `is_virgin_node/0`, `dir/0` and `ensure_dir_exists/0` functions
2023-01-13 16:26:06 +01:00
Jean-Sébastien Pédron 950c4ef7eb
Use `rabbit:data_dir/0` instead of `rabbit_mnesia:dir/0` where it makes sense
Some testcases are interested in RabbitMQ data directory, not Mnesia
directory per se. In this case, call `rabbit:data_dir/0` instead.
2023-01-13 11:56:21 +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
Jean-Sébastien Pédron 46b71e8994
rabbitmq-cli: Deleting a non-existing user or vhost is fine
This patch adapts several testcases to this behavior change. The goal is
to avoid transactions where there is no need for one.
2022-12-14 10:06:45 +01:00
Jean-Sébastien Pédron b25175563c
rabbitmq-cli: Fix several testcases which didn't test anything
RabbitMQ lacks argument verifications in many places unfortunately.
Several testcases were passing bad arguments to the command but were
also comparing the result to bad data. This happened to "work"...
2022-12-13 14:55:46 +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 1b1fdfbed5
Merge pull request #6316 from rabbitmq/rabbitmq-server-6289
CLI tools: discover commands in plugins that are enabled indirectly as dependencies; rework plugin state assertions
2022-11-03 17:19:27 +04: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
Philip Kuryloski 6c3664d871 Filter the rabbitmq_cli format check out on windows
When I ran it manually, all files were reported as mis-formatted. I
didn't investigate further, may line endings or encoding is an issue?
It seems worth it to skip the check for now since we don't run
integration test on windows with bazel yet anyway.
2022-11-02 14:24:44 +01:00
Rin Kuryloski bff69d325c Fixup format check on windows 2022-11-02 11:50:42 +01:00
Michael Klishin 6ebbfaa0a4
Adopt new helpers that assert on plugin presence and state
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.
2022-11-02 14:07:10 +04:00
Rin Kuryloski cb935a034e Reduce unnecessary setup in rabbitmq_cli formatting check 2022-11-02 10:41:30 +01:00
Rin Kuryloski d15599940d Split rabbitmq_cli format check into a separate test target in bazel
`bazel test //deps/rabbitmq_cli:all` runs tests and format check
`bazel test //deps/rabbitmq_cli:tests` runs just the tests
`bazel test //deps/rabbitmq_cli:check_formatted` runs just the format
check
2022-11-02 10:17:08 +01:00
Michael Klishin 8c6b3bfbc6
CLI: continue reworking assertions on plugin state 2022-11-02 13:08:44 +04:00
Michael Klishin e1d14bac2d
Reset enabled plugins after each test that enables any 2022-11-02 13:08:44 +04:00
Simon Unge cd1ac5b66c
See Issue 6020. Add rabbitmq_stream_management plugin to test suite 2022-11-02 13:08:44 +04:00
Simon Unge 917bf55e19
See Issue 6020. Take plugin dependency into account 2022-11-02 13:08:44 +04:00
Rin Kuryloski 278025f514 Copy rather than symlink files in rabbitmqctl_test.bzl
Bazel seems to be cleaning up files after following directory symlinks
after the test. Not what I would have expected, and maybe a
consequence of lighter sandboxing used on macos with rabbitmq. In any
case copying seems to be a reasonable workaround.
2022-11-02 09:49:38 +01:00
Michael Klishin e7e88d4dc4
Explain that 'bazel clean' helps with this odd condition 2022-11-02 09:50:08 +04:00
Rin Kuryloski 55a9245493 Fail fast in the rabbitmq_cli tests if test_helper.exs is missing
For reasons which are not yet fully understood, this file can go
missing and require a `bazel clean` to get the suite working
again. Having this check in place should make future flakes easier to
diagnose, and help determine if subsequent symlinking in the
underlying bazel rule should be replaced with copying, or if something
else altogether is happening.
2022-11-01 17:05:53 +01: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
Jean-Sébastien Pédron 4b132daaba
Remove upgrade-specific log file
This category should be unused with the decommissioning of the old
upgrade subsystem (in favor of the feature flags subsystem). It means:
1. The upgrade log file will not be created by default anymore.
2. The `$RABBITMQ_UPGRADE_LOG` environment variable is now unsupported.

The configuration variables remain to avoid breaking an existing and
working configuration.
2022-10-06 21:28:50 +02:00
Rin Kuryloski a71ff1341e Add 'mix format --check-formatted' to the rabbitmqctl_tests in bazel
to match the check on the Makefile side that was recently introduced
2022-10-04 14:59:45 +02:00
Ayanda Dube c4b42f6c50 add rabbitmq_cli format check on make/mix task aliases 2022-10-02 19:07:08 +01:00
Ayanda Dube 345a580f6d remove deprecated and replace with import Config module 2022-10-02 18:56:48 +01:00
Ayanda Dube 4cbbaad2df mix format rabbitmq_cli 2022-10-02 18:54:11 +01:00
Ayanda Dube 56ca86a48e initial .formatter.exs configuration file 2022-10-02 18:52:43 +01:00
Michael Klishin 7780c594eb Require Elixir 1.13.4 or 1.14.x 2022-09-18 22:25:42 +04:00
Michael Klishin 8db79fadda
Merge branch 'main' into rabbitmq-server-5708-whitelist-elixir-1.14 2022-09-03 01:15:30 +04:00
Michael Klishin e40a121c80 Make CLI tools version reflect that of RabbitMQ itself on this branch 2022-09-03 00:32:13 +04:00
Michael Klishin 7914e60d6a CLI tools: whitelist Elixir 1.14
As suggested by @VlkrS in #5708
2022-09-03 00:30:23 +04: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
Rin Kuryloski 165f946ffd Remove .travis.yml.patch files 2022-08-16 09:48:46 +02:00
Rin Kuryloski 575c5f9975 Remove all of the .travis.yml files
since we no longer use them
2022-08-16 09:46:31 +02: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
Jean-Sébastien Pédron 5b98d7d2a2
Remove test code which depended on the `maintenance_mode_status` feature flags
These checks are now irrelevant as the feature flag is required.
2022-07-29 11:51:52 +02:00
Rin Kuryloski e9c1e6b680 Bump the rabbitmq version on this branch to 3.12.0 (bazel)
To reduce cache misses, the bazel build uses a hard coded version. A
correct value is injected in releases.
2022-07-28 09:45:26 +02:00
Rin Kuryloski 59b858de54 Revert "Fixup an accidental backport side-effect"
This reverts commit 5053d48bce.
2022-07-27 14:03:01 +02:00
Rin Kuryloski 5053d48bce
Fixup an accidental backport side-effect 2022-07-27 14:02:35 +02:00
Rin Kuryloski f67eaaae68 Use code compiled with -DTEST in mixed version testing
Also introduces an actions workflow to provide the necessary archives
referenced in secondary_umbrella.bzl
2022-07-26 20:29:33 +02: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
Jean-Sébastien Pédron bcb8733880
rabbit_feature_flags: Add a feature flags controller process
This gen_statem-based process is responsible for handling concurrency
when feature flags are enabled and synchronized when a cluster is
expanded.

This clarifies and stabilizes the behavior of the feature flag subsystem
w.r.t. situations where e.g. a feature flag migration function takes
time to update data and a new node joins a cluster and synchronizes its
feature flag states with the cluster. There was a chance that the
feature flag was marked as enabled on the joining node, even though the
migration function didn't take care of that node.

With this new feature flags controller, enabling or synchronizing
feature flags blocks and delays any concurrent operations which try to
modify feature flags states too.

This change also clarifies where and when the migration function is
called: it is called at least once on each node who knows the feature
flag and when the state goes from "disabled" to "enabled" on that node.

Note that even if the feature flag is being enabled on a subset of the
nodes (because other nodes already have it enabled), it is marked as
"state_changing" everywhere during the migration. This is to prevent
that a node where it is enabled assumes it is enabled on all nodes who
know the feature flag.

There is a new feature as well: just after a feature flag is enabled,
the migration function is called a second time for any post-enable
actions. The feature flag is marked as enabled between these "enable"
and "post-enable" steps. The success or failure of this "post-enable"
run does not affect the state of the feature flag (i.e. it is ignored).

A new migration function API is introduced to allow more advanced
things. The new API is:

    my_migration_function(
      #ffcommand{name = ...,
                 props = ...,
		 command = enable | post_enable,
		 extra = #{...}})

The record is defined in `include/feature_flags.hrl`. Here is the
meaning of each field:

* `name` and `props` are the equivalent of the `FeatureName` and
  `FeatureProps` arguments of the previous migration function API.

* `command` is basically the same as the previous `Arg` arguments.

* `extra` is map containing context-specific information. For instance, it
  contains the list of nodes where the feature flag state changes.

This whole new behavior is behind a new feature flag called
`feature_flags_v2`. If a feature flag uses the new migration function
API, `feature_flags_v2` will be automatically enabled.

If many feature flags are enabled at once (like when a fresh RabbitMQ
node is started for the first time), `feature_flags_v2` will be enabled
first if it is in the list.
2022-06-28 10:13:19 +02:00
Jean-Sébastien Pédron 3eb6374e4e
rabbitmq_cli: Take "make" command from $MAKE env. variable
This unbreaks the build of rabbitmq_cli on platforms where GNU Make is
installed under another name than `make`. This is the case on Mac OSX
and *BSD for instance where GNU Make is available as `gmake`.
2022-06-20 11:36:02 +02:00
Philip Kuryloski 09fa85e570 Remove extra tar options not supported on macos
They would have improved the reproducibility of the :source_archive
rule, but are not essential. Fixes the macos breakage introduced by
5027.
2022-06-14 17:53:49 +02:00
Philip Kuryloski 34db1a3c38 Add a rule for building a source archive
that includes the external dependencies
2022-06-14 10:44:09 +02:00
Philip Kuryloski f52efbb909 Fixup rabbitmqctl build for missing formatters & otp 25 2022-06-13 12:08:57 +02:00
Philip Kuryloski 0b676e925f Again bump rules_erlang 2022-06-08 14:04:59 +02:00
Philip Kuryloski 327f075d57 Make rabbitmq-server work with rules_erlang 3
Also rework elixir dependency handling, so we no longer rely on mix to
fetch the rabbitmq_cli deps

Also:

- Specify ra version with a commit rather than a branch
- Fixup compilation options for erlang 23
- Add missing ra reference in MODULE.bazel
- Add missing flag in oci.yaml
- Reduce bazel rbe jobs to try to save memory
- Use bazel built erlang for erlang git master tests
- Use the same cache for all the workflows but windows
- Avoid using `mix local.hex --force` in elixir rules
  - Fetching seems blocked in CI, and this should reduce hex api usage in
    all builds, which is always nice
- Remove xref and dialyze tags since rules_erlang 3 includes them in
  the defaults
2022-06-08 14:04:53 +02:00
Michael Klishin 727fe6ca4e
Update CLI build requirements to match our pipelines 2022-06-05 16:36:53 +04:00