Commit Graph

2244 Commits

Author SHA1 Message Date
Luke Bakken 3280bed8ac
Additional JSON CLI formatter fix (#14511)
A list of binaries was incorrectly converted by
`unicode:characters_to_binary` into one big binary. Add a function head
to match this case.

Also, add tests for the values that were not correctly formatted prior
to #14101 and #14381
2025-09-05 12:29:29 -07:00
Péter Gömöri bfa38d00b0 Fix docs: list_unresponsive_queues queue-timeout is in seconds
The unit was changed in commit 829a918c
2025-08-28 14:06:05 +02:00
Luke Bakken 3e235a6316
Do not "pre convert" `running_nodes` to strings
Follow-up to #14118
2025-08-13 12:01:18 -07:00
Jean-Sébastien Pédron 8d0f1001af
rabbitmq_cli: Create a symlink to test node's logs
[Why]
This doesn't replicate the common_test logs layout, but it will be good
enough to let our GitHub Actions workflow to upload the logs without
specific instructions in the workflow.
2025-08-08 10:12:56 +02:00
Luke Bakken 959be5945a
Changes required to use `zip` instead of `7z` 2025-07-28 09:45:58 -07:00
Ayanda Dube e8a3c4db42 remove IO.inspect/1 in ctl status command 2025-07-22 11:33:36 +01:00
Michal Kuratczyk 9ffcf0123b
Bump x509 to 0.9.2 2025-07-18 15:47:35 +02:00
Michal Kuratczyk e459859a40
Remove test for rabbit_log:log/4 2025-07-18 08:43:05 +02:00
Michal Kuratczyk 9ab45124e6
rabbit_log -> logger in CLI tests 2025-07-18 08:43:04 +02:00
Michal Kuratczyk e7c2dc5aff
Show current state of deprecated features 2025-07-14 15:56:28 +02:00
Michal Kuratczyk 2808154f39
CLI: ignore the exact error message
There error is slightly different for different Elixir versions
2025-07-08 10:52:24 +02:00
Michal Kuratczyk 6def891d42
Adjust CLI tests for OTP28 2025-06-27 12:42:57 +02:00
Michal Kuratczyk ad0c873c6b
rabbitmq_cli: bump temp to 0.4.9 2025-06-27 12:42:56 +02:00
Michal Kuratczyk edd1b6dc6f
Bump x509 to 0.9.0 for OTP28 support 2025-06-27 12:42:56 +02:00
Luke Bakken 33cb21ee92
Follow up to #14132
#14132 introduced a small bug in the JSON output that was caught by CI.
2025-06-25 12:01:49 -07:00
Luke Bakken 00528cb1e8
Follow-up to 14101
Improvement in the code that @the-mikedavis noticed just before #14118 was merged.
2025-06-25 08:04:49 -07:00
Luke Bakken 75cd74a2f2
Fix JSON output for `rabbitmqctl environment`
Fixes #14101
2025-06-24 13:20:26 -07:00
Diana Parra Corbacho 597fb419f3 Update rabbitmq_cli federation test dependency 2025-05-27 07:55:29 +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
Jean-Sébastien Pédron a34ce08f8f
rabbitmq_cli: Adapt `force_reset_command_test.exs` testsuites
[Why]
`force_reset` is unsupported with Khepri.
2025-04-23 11:34:37 +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
Aitor Pérez Cedres dcd5415a18
Merge pull request #13514 from rabbitmq/remove-bazel-files
Remove Bazel files
2025-03-14 12:06:19 +00: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
Aitor Perez 07adc3e571
Remove Bazel files 2025-03-13 13:42:34 +00:00
Michael Klishin cf1bfa0b15
CLI: remove a non-essential flaky test 2025-03-12 19:01:55 -04:00
Michael Klishin b023062749
CLI distribution_test.exs: skip it on CI
it flakes specifically on CI. We can afford
to skip this specific test there and only
run it locally.
2025-03-12 18:33:13 -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
Volker Schlecht 5086e283bd
Allow building CLI with elixir 1.18.x
Tested with elixir 1.18.0-rc0
2024-12-12 19:30:04 +01:00
Michael Klishin 9b6ab77f87
CLI: test/diagnostics cosmetics #12894 2024-12-04 13:44:29 -05:00
Michael Davis 430cd2f578
CLI: Compile and test with --warnings-as-errors 2024-12-04 11:19:55 -05:00
Michael Davis 9f60325563
CLI: Silence `status` command test
This check is expected to succeed and the status is expected to be
printed to stdout rather than stderr. This change silences the status
output. The status text was printed mistakenly previously because we
captured stderr rather than stdout.
2024-12-04 11:10:46 -05:00
Michael Davis c328922a2a
CLI: Fix match of discover peers command test
This previously emitted a warning because Elixir will rebind `this_node`
by default, so the `this_node` binding in the line above was unused.
(As opposed to Erlang which would treat this as a match - rejecting
the binding if `this_node` was not equal to the value being matched.)
The node needed to be adjusted as well - `node()` returned the ExUnit
runner's node while the command returned the remote node, which is
stored in the context under `opts.node`.
2024-12-04 11:07:46 -05:00