Commit Graph

1410 Commits

Author SHA1 Message Date
Iliia Khaprov be38f5c317
Make queue commands generic - i.e. make them work with any queue type 2025-06-24 18:26:26 +02:00
Aaron Seo fa310864d7 Fix force_checkpoint tests and CLI command
(cherry picked from commit 12bf3e094e)

Conflicts:
	deps/rabbit/src/rabbit_quorum_queue.erl
2025-05-22 15:09:23 +02:00
Aaron Seo 0d3dfd9695 Add force checkpoint functions for quorum queues and command line tool
(cherry picked from commit b54ab1d5e5)
2025-05-22 14:58:12 +02:00
Loïc Hoguin c5d150a7ef
Use Erlang.mk's native Elixir support for CLI
This avoids using Mix while compiling which simplifies
a number of things and let us do further build improvements
later on.

Elixir is only enabled from within rabbitmq_cli currently.

Eunit is disabled since there are only Elixir tests.

Dialyzer will force-enable Elixir in order to process
Elixir-compiled beam files.

This commit also includes a few changes that are
related:

 * The Erlang distribution will now be started for parallel-ct

 * Many unnecessary PROJECT_MOD lines have been removed

 * `eunit_formatters` has been removed, it provides little value

 * The new `maybe_flock` Erlang.mk function is used where possible

 * Build test deps when testing rabbitmq_cli (Mix won't do it anymore)

 * rabbitmq_ct_helpers now use the early plugins to have Dialyzer
   properly set up
2025-03-18 10:02:49 +01:00
Michael Klishin 4bb21d7549
RMQ-1263 CLI tools: replace Erlang files with Elixir
otherwise we end up with two copies of the compiled
module on the code path some of the time.

We don't need to mix Erlang and Elixir even
more to bring in one constant that hasn't changed
since its introduction some eight years ago.

(cherry picked from commit c32b948258f226a86be91cab80448d7a536afd7d)
2025-03-14 00:06:18 -04:00
Diana Parra Corbacho d2f66ced1b
RMQ-1263: Add a --force option to rabbitmqctl delete_queue command
RMQ-1263: Add a --force option to rabbitmqctl delete_queue command.

This work was originally done by Iliia Khaprov <iliia.khaprov@broadcom.net>.

---------

Co-authored-by: Iliia Khaprov <iliia.khaprov@broadcom.net>
Co-authored-by: Michael Klishin <klishinm@vmware.com>
(cherry picked from commit d9522d3ee708250cc84443af5c3556b14f7c5ab9)
2025-03-14 00:06:09 -04:00
Michael Klishin 69bd5ef0e0
Merge pull request #13485 from cloudamqp/no_obs_cli_in_cli
Minor improvement: Remove observer_cli from CLI escritps
2025-03-12 15:18:13 -04:00
Michael Klishin 09f1ab47b7
By @Ayanda-D: new CLI health check that detects QQs without an elected reachable leader #13433 (#13487)
* Implement rabbitmq-queues leader_health_check command for quorum queues

(cherry picked from commit c26edbef33)

* Tests for rabbitmq-queues leader_health_check command

(cherry picked from commit 6cc03b0009)

* Ensure calling ParentPID in leader health check execution and
reuse and extend formatting API, with amqqueue:to_printable/2

(cherry picked from commit 76d66a1fd7)

* Extend core leader health check tests and update badrpc error handling in cli tests

(cherry picked from commit 857e2a73ca)

* Refactor leader_health_check command validators and ignore vhost arg

(cherry picked from commit 6cf9339e49)

* Update leader_health_check_command description and banner

(cherry picked from commit 96b8bced2d)

* Improve output formatting for healthy leaders and support
silent mode in rabbitmq-queues leader_health_check command

(cherry picked from commit 239a69b404)

* Support global flag to run leader health check for
all queues in all vhosts on local node

(cherry picked from commit 48ba3e161f)

* Return immediately for leader health checks on empty vhosts

(cherry picked from commit 7873737b35)

* Rename leader health check timeout refs

(cherry picked from commit b7dec89b87)

* Update banner message for global leader health check

(cherry picked from commit c7da4d5b24)

* QQ leader-health-check: check_process_limit_safety before spawning leader checks

(cherry picked from commit 17368454c5)

* Log leader health check result in broker logs (if any leaderless queues)

(cherry picked from commit 1084179a2c)

* Ensure check_passed result for leader health internal calls)

(cherry picked from commit 68739a6bd2)

* Extend CLI format output to process check_passed payload

(cherry picked from commit 5f5e9922bd)

* Format leader healthcheck result log and function exports

(cherry picked from commit ebffd7d8a4)

* Change leader_health_check command scope from queues to diagnostics

(cherry picked from commit 663fc9846e)

* Update (c) line year

(cherry picked from commit df82f12a70)

* Rename command to check_for_quorum_queues_without_an_elected_leader
and use across_all_vhosts option for global checks

(cherry picked from commit b2acbae28e)

* Use rabbit_db_queue for qq leader health check lookups
and introduce rabbit_db_queue:get_all_by_type_and_vhost/2.
Update leader health check timeout to 5s and process limit
threshold to 20% of node's process_limit.

(cherry picked from commit 7a8e166ff6)

* Update tests: quorum_queue_SUITE and rabbit_db_queue_SUITE

(cherry picked from commit 9bdb81fd79)

* Fix typo (cli test module)

(cherry picked from commit 615856853a)

* Small refactor - simpler final leader health check result return on function head match

(cherry picked from commit ea07938f3d)

* Clear dialyzer warning & fix type spec

(cherry picked from commit a45aa81bd2)

* Ignore result without strict match to avoid diayzer warning

(cherry picked from commit bb43c0b929)

* 'rabbitmq-diagnostics check_for_quorum_queues_without_an_elected_leader' documentation edits

(cherry picked from commit 845230b0b380a5f5bad4e571a759c10f5cc93b91)

* 'rabbitmq-diagnostics check_for_quorum_queues_without_an_elected_leader' output copywriting

(cherry picked from commit 235f43bad58d3a286faa0377b8778fcbe6f8705d)

* diagnostics check_for_quorum_queues_without_an_elected_leader: behave like a health check w.r.t. error reporting

(cherry picked from commit db7376797581e4716e659fad85ef484cc6f0ea15)

* check_for_quorum_queues_without_an_elected_leader: handle --quiet and --silent

plus simplify function heads.

References #13433.

(cherry picked from commit 7b392315d5e597e5171a0c8196230d92b8ea8e92)

---------

Co-authored-by: Ayanda Dube <adube14@bloomberg.net>
2025-03-12 00:32:59 -04:00
Péter Gömöri f9d3ed732b Remove observer_cli from CLI escritps
observer_cli (and its dependency recon) was declared as a dependency
of rabbitmq_cli and as a consequence included in all escritps. However
the major part of observer_cli runs in the broker. The cli side only
used `observer_cli:rpc_start/2` which is just an rpc call into the
target node.

By using common rpc call we can remove observer_cli and recon from the
escripts. This can be considered a minor improvement based on the
philosophy "simpler is better".

As an additional benefit auto-completing functions of the recon app
now works in `rabbitmq-diagnostics remote_shell`.
(eg. `recon:proc_c<TAB>`)
2025-03-12 00:07:04 +01:00
Mirah Gary 34ef4c4e6a
Fix error message to reflect command. 2025-03-04 10:57:28 +01:00
Arnaud Cogoluègnes 7ea2ff2651
Remove set_stream_retention_policy command
It is not working as expected. Policies are the way to change data retention for stream.
2025-02-18 11:06:04 +01:00
Michal Kuratczyk 7e8ecc96db
CLI: Don't use regex as module attributes
When trying to use OTP28.0-rc1, Elixir fails to compile these modules
because a module attribute cannot be a regex. It is not yet clear
whether it's something to be fixed in Elixir for OTP28 compatibility
or something that accidentally worked in the past, but either way,
using a string as an attribute is equally good and works all OTP
versions, including OTP28.0-rc1.

```
== Compilation error in file lib/rabbitmq/cli/core/command_modules.ex ==
** (ArgumentError) cannot inject attribute @commands_ns into function/macro because cannot escape #Reference<0.2201422310.1333657602.13657>. The supported values are: lists, tuples, maps, atoms, numbers, bitstrings, PIDs and remote functions in the format &Mod.fun/arity
    (elixir 1.18.2) lib/kernel.ex:3729: Kernel.do_at/5
    (elixir 1.18.2) expanding macro: Kernel.@/1
    lib/rabbitmq/cli/core/command_modules.ex:133: RabbitMQ.CLI.Core.CommandModules.make_module_map/2
```
2025-02-17 11:56:30 +01:00
Michael Klishin b8fccd96ed
'rabbitmq diagnostics check_if_metadata_store_is_initialized*': support --formatter=json 2025-01-28 19:26:54 -05:00
Michael Klishin 07ec1b4b50
New health check CLI commands 2025-01-28 16:44:37 -05:00
David Ansari 579c58603e Support AMQP over WebSocket (OSS part) 2025-01-27 17:50:47 +01:00
Michael Klishin 643a58fdce
ctl import definitions: correct usage
it is likely a copy-paste artifact from
'ctl export_definitions' which does use '-'
as a target.

References #13157
2025-01-26 18:06:03 -05:00
Michael Klishin 5c7d643ab3
CLI: drop an unused import 2025-01-07 18:50:02 -05:00
Michael Klishin bcb080179c
Improve documentation of certain health checks
in the HTTP API documentation reference
as well as one CLI command that apparently
needed a clarification.
2025-01-07 18:48:39 -05:00
Michael Klishin 6281dcb798
CLI commands for #12772 2025-01-02 18:35:31 -05:00
Michael Klishin 3f5b13d47f
Merge branch 'main' into mk-virtual-host-protection-from-accidental-deletion 2025-01-02 17:01:54 -05:00
Michael Klishin c95a95f822
CLI: mix format 2025-01-02 17:00:46 -05:00
Michael Klishin f62d46c286
Introduce a way to protect a virtual host from deletion
Accidental "fat finger" virtual deletion accidents
would be easier to avoid if there was a protection mechanism
that would apply equally even to CLI tools and external
applications that do not use confirmations for deletion
operations.

This introduce the following changes:

 * Virtual host metadata now supports a new queue,
   'protected_from_deletion', which, when set,
   will be considered by key virtual host deletion function(s)
 * DELETE /api/vhosts/{name} was adapted to handle
   such blocked deletion attempts to respond with
   a 412 Precondition Failed status
 * 'rabbitmqctl list_vhosts' and 'rabbitmqctl delete_vhost'
   were adapted accordingly
 * DELETE /api/vhosts/{name}/deletion/protection
   is a new endpoint that can be used to remove
   the protective seal (the metadata key)
 * POST /api/vhosts/{name}/deletion/protection
   marks the virtual host as protected

In the case of the HTTP API, all operations on
virtual host metadata require administrative
privileges from the target user.

Other considerations:

 * When a virtual host does not exist, the behavior
  remains the same: the original, protection-unaware
  code path is used to preserve backwards compatibility

References #12772.
2025-01-02 16:50:51 -05:00
Michael Klishin 968eefa1bb
Bump (c) line year
There are no functional changes to this massive diff.
2025-01-01 17:54:10 -05:00
Michael Davis d58d874a0b
CLI: Resolve elixirc warnings 2024-12-04 11:07:34 -05:00
Jean-Sébastien Pédron 58c609c4e7
rabbitmq_cli: Fix typo in an error message in `join_cluster` 2024-12-02 11:51:24 +01:00
Michael Klishin d0b66b8c8f
check_certificate_expiration_command.ex: squash a compiler warning 2024-11-27 18:26:34 -05:00
Michael Klishin 1cae417dbf
Merge pull request #12821 from rabbitmq/rabbitmq-server-12776
Definition export: inject default queue type into virtual host metadata
2024-11-27 14:53:25 -05:00
Michael Klishin f377e8f9f0
Cosmetics 2024-11-27 12:44:17 -05:00
Michael Klishin 3e9c6a95df
Explain why list_vhosts does not list metadata such as DQT by default 2024-11-27 07:27:54 -05:00
Michael Klishin 93fd1dcda1
Drop release_series_support_status from overview and status
This undocumented key used to use a simple date-based
formula and used to help support and the core
team.

Nodes no longer have the context to return
a correct response, so all we can do is drop this
key.
2024-11-24 17:56:57 -05:00
Michael Klishin d5063c7076
Merge pull request #12675 from rabbitmq/fix-check_if_any_deprecated_features_are_used-cli-command
CLI: Finish `check_if_any_deprecated_features_are_used` implementation
2024-11-14 13:57:40 -05:00
Michael Klishin 94c8f01699
rabbitmq-diagnostics status: handle output of 3.13.x and previously released 4.0.x nodes
In a mixed cluster environment,
'rabbitmq-diagnostics status' can hit a node
that does not return any node tags.

Be more defensive and handle such cases
by simply displaying "(none)" for such
values.
2024-11-11 17:41:33 -05:00
Simon Unge 3d35416635 Node tags local to broker, add to /api/overview output and ctl status command 2024-11-11 20:49:21 +00:00
Jean-Sébastien Pédron ddaea6facb
CLI: Finish `check_if_any_deprecated_features_are_used` implementation
[Why]
The previous implementation bypassed the deprecated features subsystem.
It only cared about classic mirrored queues and called some
queue-related code directly to determine if this specific feature was
used.

[How]
The command code is simplified by calling the deprecated subsystem to
list used deprecated features instead.

References #12619.
2024-11-11 10:13:25 +01:00
Simon Unge eeea517da5 Store tags in global parameters 2024-11-08 21:41:49 +00:00
Simon Unge f5ef64ad06 Add cluster tag config that is exposed via HTTP /api/overview and CTL cluster_status 2024-11-08 21:05:02 +00:00
Michael Klishin 80f4797e76 Remove multiple mentions of global prefetch
As suggested by @johanrhodin in #12454.

This keeps the Prometheus plugin part but
marks it as deprecated. We can remove it in
4.1.
2024-10-04 20:47:37 -04:00
Michael Klishin 47210c8307
cli enable_feature_flag: alias --experimental as --opt-in
--experimental is no longer particularly fair to Khepri,
which is not enabled by default because of its enormous
scope, and because once enabled, it cannot be disabled.

--opt-in would be a better name but --experimental
remains for backwards compatiblity.

When both are specified, we consider that the
user opts in if at least one of the flags is
set to true.
2024-09-17 19:08:28 -04:00
David Ansari f78f14ab1d Display container-id in the UI and CLI 2024-09-13 17:05:46 +02:00
Michal Kuratczyk 9b828c08b7
Remove HiPE 2024-08-28 09:18:28 +02:00
Michael Klishin f47daee915 Wording #12113 2024-08-24 19:07:09 -04:00
Michal Kuratczyk b48d4bf29a
Don't return khepri status when khperi_db is disabled
When khepri_db feature flag is disabled, Khepri servers
are running but are not clustered. In this case `rabbit_khepri:status/0`
shows that all nodes are leaders, which is confusing and scary
(even though actually harmless). Instead, we now just print that mnesia
is in use.
2024-08-22 11:01:46 +02:00
Michael Davis dc611dd45c
Non-zero exit code for failing to enable an experimental feature flag
With the prior behavior it can be unclear whether the text was a warning
and the feature flag was enabled anyways. We can use a non-zero exit
code and the `{:error, code, text}` return value to make it clear that
the flag wasn't enabled.
2024-08-20 16:03:29 -04:00
Michael Davis f0c0cf8052
enable_feature_flag CLI: Fix typo in usage message 2024-08-20 15:25:20 -04:00
Michal Kuratczyk 396ad7af1a Reject `--experimental all` 2024-08-19 13:41:37 -04:00
Michal Kuratczyk ddb117f810 `-f` -> `-e`; drop unneeded cases; typos
Also, remove the `undef` case which was only needed for
RabbitMQ 3.7 and older.
2024-08-19 13:41:37 -04:00
Michal Kuratczyk e3302f2f9a Rename --force to --experimental
Plus, a slightly more scary error message
2024-08-19 13:41:37 -04:00
Michal Kuratczyk 58e0c1600f Require --force to enable experimental FF 2024-08-19 13:41:37 -04:00
Michael Klishin bd1e953b95 Configuration value encryption CLI commands: unconditionally print stack traces 2024-08-13 14:31:55 -04:00
Michael Klishin e1490c6d9c More CLI commands for tagged values 2024-08-13 14:26:02 -04:00