Commit Graph

465 Commits

Author SHA1 Message Date
Michael Klishin ef14bf067e
ctl add_vhost: propagate tags if no description is given 2021-07-18 08:28:53 +03:00
Michael Klishin a5373d71d6
Make it possible to update virtual host tags
Currently they can only be specified at creation time
2021-05-01 21:48:50 +03:00
Jean-Sébastien Pédron cdcf602749
Switch from Lager to the new Erlang Logger API for logging
The configuration remains the same for the end-user. The only exception
is the log root directory: it is now set through the `log_root`
application env. variable in `rabbit`. People using the Cuttlefish-based
configuration file are not affected by this exception.

The main change is how the logging facility is configured. It now
happens in `rabbit_prelaunch_logging`. The `rabbit_lager` module is
removed.

The supported outputs remain the same: the console, text files, the
`amq.rabbitmq.log` exchange and syslog.

The message text format slightly changed: the timestamp is more precise
(now to the microsecond) and the level can be abbreviated to always be
4-character long to align all messages and improve readability. Here is
an example:

    2021-03-03 10:22:30.377392+01:00 [dbug] <0.229.0> == Prelaunch DONE ==
    2021-03-03 10:22:30.377860+01:00 [info] <0.229.0>
    2021-03-03 10:22:30.377860+01:00 [info] <0.229.0>  Starting RabbitMQ 3.8.10+115.g071f3fb on Erlang 23.2.5
    2021-03-03 10:22:30.377860+01:00 [info] <0.229.0>  Licensed under the MPL 2.0. Website: https://rabbitmq.com

The example above also shows that multiline messages are supported and
each line is prepended with the same prefix (the timestamp, the level
and the Erlang process PID).

JSON is also supported as a message format and now for any outputs.
Indeed, it is possible to use it with e.g. syslog or the exchange. Here
is an example of a JSON-formatted message sent to syslog:

    Mar  3 11:23:06 localhost rabbitmq-server[27908] <0.229.0> - {"time":"2021-03-03T11:23:06.998466+01:00","level":"notice","msg":"Logging: configured log handlers are now ACTIVE","meta":{"domain":"rabbitmq.prelaunch","file":"src/rabbit_prelaunch_logging.erl","gl":"<0.228.0>","line":311,"mfa":["rabbit_prelaunch_logging","configure_logger",1],"pid":"<0.229.0>"}}

For quick testing, the values accepted by the `$RABBITMQ_LOGS`
environment variables were extended:
  * `-` still means stdout
  * `-stderr` means stderr
  * `syslog:` means syslog on localhost
  * `exchange:` means logging to `amq.rabbitmq.log`

`$RABBITMQ_LOG` was also extended. It now accepts a `+json` modifier (in
addition to the existing `+color` one). With that modifier, messages are
formatted as JSON intead of plain text.

The `rabbitmqctl rotate_logs` command is deprecated. The reason is
Logger does not expose a function to force log rotation. However, it
will detect when a file was rotated by an external tool.

From a developer point of view, the old `rabbit_log*` API remains
supported, though it is now deprecated. It is implemented as regular
modules: there is no `parse_transform` involved anymore.

In the code, it is recommended to use the new Logger macros. For
instance, `?LOG_INFO(Format, Args)`. If possible, messages should be
augmented with some metadata. For instance (note the map after the
message):

    ?LOG_NOTICE("Logging: switching to configured handler(s); following "
                "messages may not be visible in this log output",
                #{domain => ?RMQLOG_DOMAIN_PRELAUNCH}),

Domains in Erlang Logger parlance are the way to categorize messages.
Some predefined domains, matching previous categories, are currently
defined in `rabbit_common/include/logging.hrl` or headers in the
relevant plugins for plugin-specific categories.

At this point, very few messages have been converted from the old
`rabbit_log*` API to the new macros. It can be done gradually when
working on a particular module or logging.

The Erlang builtin console/file handler, `logger_std_h`, has been forked
because it lacks date-based file rotation. The configuration of
date-based rotation is identical to Lager. Once the dust has settled for
this feature, the goal is to submit it upstream for inclusion in Erlang.
The forked module is calld `rabbit_logger_std_h` and is based
`logger_std_h` in Erlang 23.0.
2021-03-11 15:17:36 +01:00
Michael Klishin 93721bfa2d
Whitelist consumer_capacity in 'rabbitmqctl list_queues' 2021-02-24 21:26:46 +03:00
Michael Klishin 17526987c6
Bump (c) year 2021-02-14 00:54:01 +03:00
Michael Klishin 3f6a42e82b
Wording 2021-02-01 20:19:22 +03:00
Michal Kuratczyk ea1f4a355a New command: `rabbitmqctl close_all_user_connections` 2021-02-01 16:04:16 +01:00
Michal Kuratczyk 5a967affdd WIP: close_all_user_connections command 2021-01-28 12:57:18 +01:00
Michael Klishin 400f6f1188
Wording and additional usage docs
(cherry picked from commit 3e3ef927b2)
2020-11-17 14:17:43 +03:00
Michal Kuratczyk ce65586405
Allow "all" as a feature flag name
`rabbitmqctl enable_feature_flag all` enables all currently disabled feature flags.
While https://github.com/rabbitmq/rabbitmq-cli/issues/455 asked for
`--all`, I decided to just use "all" for consistency with
`rabbitmq-queues rebalance all`.

Closes rabbitmq/rabbitmq-cli#455

(cherry picked from commit af9e877848)
2020-11-17 14:17:35 +03:00
Michael Klishin 4f7db32452 Provide an extra hint in 'rabbitmqctl add_user' output
to give the user an idea that she would have to
grant permissions to the newly added user.
2020-10-25 16:43:37 +03:00
dcorbacho d7aaf7bccb Add relevant info keys for stream and quorum queues 2020-10-19 15:57:08 +01:00
dcorbacho ece0aa7609 Shrink quorum queues on forget cluster node command
When the node is offline we can only offer a warning - operator
must use the shrink command once the node is restarted
2020-09-25 15:06:39 +01:00
Michael Klishin bf12dc98fa set_user_limits: mention <username> in parameter docs 2020-08-25 20:24:18 +03:00
Michael Klishin 9b8b7436e8 Wording 2020-08-25 19:09:00 +03:00
Michael Klishin 3d621a5984 Include total amount of memory used into 'rabbitmq-diagnostics status' output
--formatter=json already reports that value.

Spotted by Jon P on rabbitmq-users and @lukebakken.
2020-08-20 14:27:31 +03:00
Ayanda-D 74c183e69e Update list_user_limits command defaults 2020-07-17 15:59:20 +01:00
Ayanda-D 30160430b2 Update license, ref: #447 2020-07-17 15:59:20 +01:00
Ayanda-D afcae06cd9 Include acting-user in user-limit operations & doc-guides 2020-07-17 15:59:20 +01:00
Anupama Singh 128201baa6 New command added to list user limits 2020-07-17 15:59:20 +01:00
Ayanda-D dbbe62e8a4 Test case added for command to set both max-connections and max-channels
Clearing all user limits
Testcase to test clearing all limits for user
2020-07-17 15:59:20 +01:00
Anupama Singh 57b95856d8 Clearing user connection/channel limits 2020-07-17 15:56:48 +01:00
Anupama Singh e02fdb63c8 Setting user connection/channel limits 2020-07-17 15:56:48 +01:00
Michael Klishin 5553a24545 Sync license headers with MPL2 in master 2020-07-14 03:54:19 +03:00
Michael Klishin c9d984eb4c Report node maintenance status in 'rabbitmq-diagnostics cluster_status'
Part of rabbitmq/rabbitmq-server#2321
2020-07-14 03:52:02 +03:00
Michael Klishin c9ed8be1bc Report node maintenance status in 'rabbitmq-diagnostics status'
Part of rabbitmq/rabbitmq-server#2321
2020-07-14 03:52:02 +03:00
Michael Klishin 30ee526b2a Add doc guide links to {suspend,resume}_listeners 2020-07-14 03:52:02 +03:00
Michael Klishin a8b5408992 Follow our standard file naming convention for commands 2020-07-14 03:52:02 +03:00
Michael Klishin 35103fe7da Introduce 'rabbitmqctl {suspend,resume}_listeners'
Not directly related to rabbitmq/rabbitmq-server#2321
but useful on its own. We've had requests for and discussions
about such commands in the past and now that Ranch supports
listener suspension, there aren't many reasons not to do it.
2020-07-14 03:52:01 +03:00
dcorbacho 679ca254f3 Switch to Mozilla Public License 2.0 (MPL 2.0) 2020-07-11 19:23:07 +01:00
Michael Klishin db662cfa59 Re-categorize some rabbitmq-diagnostics commands
For a couple of reasons:

 * The Observability, Monitoring and Health Checks group has grown too large
 * Some commands in it clearly have to do with exploring effective node
   or CLI tool configuration, not its dynamically changing operational state
2020-07-05 15:35:32 +07:00
Michael Klishin 2101043257 Introduce a first class autocomplete command
Currently we have a --auto-complete magic argument which
does not show up in `help` and requires its argument to be
explcitly -- separated from the actual flag, which is
counter-intuitive.

This introduces a new autocomplete command which is delegated
to by --auto-complete, much like --help is simply a special
way of invoking the `help` command.

Closes #439
2020-07-02 07:29:40 +03:00
Michael Klishin 18a3daf9be rabbitmqctl eval: consume multiple lines from standard input
Part of #438
2020-07-01 16:55:33 +03:00
Michael Klishin a98e38dd80 Introduce 'rabbitmqctl eval_file [file path]'
for evaluation of scripts in environments where standard input
redirection is not an option or problematic, e.g.
certain Windows environments.

Closes #438
2020-07-01 03:11:13 +03:00
Michael Klishin 0f1f6d2be7 'rabbitmqctl eval': accept expression to evaluate from stdin
References #438
2020-07-01 02:29:22 +03:00
Michael Klishin 921d349e37 Make --help, help usage help messages consistent
* `help` printed an "Error:" at the top for no reason
 * `help [command]` with a non-existent command did not offer a suggestion
   like an attempt to invoke a non-existent command would
 * Exit codes were not consistent
 * `help --list-commands` had line break issues

With this change,

  * `help` is consistent with --help
  * `help [command]` is consistent with `[command] --help`
  * If a command is not found, either during the execution flow
    or `help [commnad]`, we consistently attempt a Jaro distance suggestion
  * Successful or effectively successful exits from the `help`
    command do not produce any error messages at the top
2020-06-29 03:57:52 +03:00
Michael Klishin ef329b88b1 rabbitmqctl export_definitions: ensure that parameter value is a map
otherwise it would be serialised as a list of pairs, which is
not the format the import path (or an operator) expects

Closes #435
2020-06-26 05:55:57 +03:00
Michael Klishin 209acc6396 Rename Rabbitmq.Atom.Coerce to RabbitMQ.CLI.Core.DataCoercion
to follow the existing core (library, utility) module
naming convention.
2020-06-26 01:34:03 +03:00
Michael Klishin d11bd12a97 Make 'rabbitmqctl hipe_compile' a no-op
HiPE has been deprecated/only partially supported in Erlang 22
and will be removed completely in Erlang 24 next year.

Part of rabbitmq/rabbitmq-server#2392
2020-06-25 18:39:12 +03:00
Michael Klishin c72f0aea41 ctl add_user: use a more suitable exit code when no password is provided
EX_DATAERR from [1] makes more sense than EX_SOFTWARE.

1. https://www.freebsd.org/cgi/man.cgi?query=sysexits&apropos=0&sektion=0&manpath=FreeBSD+12.0-RELEASE&arch=default&format=html
2020-06-13 13:04:47 +03:00
Michael Klishin 6986086b88 User and permission management command: adopt a more suitable exit code
Apparently [1], which is the most standardized set of exit codes
we could find, includes a dedicated exit code for cases where
a user does not exist.

References #425, rabbitmq/rabbitmq-server#2363, bda0cbfdc3.

1. https://www.freebsd.org/cgi/man.cgi?query=sysexits&apropos=0&sektion=0&manpath=FreeBSD+12.0-RELEASE&arch=default&format=html
2020-06-08 05:35:33 +03:00
Michael Klishin e01753ed7a Deprecate 'ctl node_health_check'
* It requires a fully booted node, so not generally suitable for a Kubernetes readiness probe.
 * It can produce false positives
 * It is too intrusive and CPU-intensive to use at scale
 * Most operators do not understand what it really does and when they learn about it,
   consider it to be too opinionated and intrusive

Time for the One True Health Check™ to retire from duty.

Part of rabbitmq/rabbitmq-cli#426
2020-06-05 00:51:40 +03:00
Michael Klishin 11b98ee091 Improve reporting of 'ctl change_password' failures
Part of rabbitmq/rabbitmq-server#2363
2020-06-04 05:56:48 +03:00
Michael Klishin b279fffc1f Improve reporting of 'ctl set_user_tags' failures
Part of rabbitmq/rabbitmq-server#2363
2020-06-04 05:51:09 +03:00
Michael Klishin 42f5a9031f Improve reporting of 'ctl delete_user' failures
Part of rabbitmq/rabbitmq-server#2363
2020-06-04 05:44:33 +03:00
Michael Klishin e4ed83ef04 Improve reporting of 'ctl add_user' failures
Part of rabbitmq/rabbitmq-server#2363
2020-06-04 05:36:51 +03:00
Michael Klishin 37b439e894 Improve reporting of 'ctl clear_topic_permissions' failures
Part of rabbitmq/rabbitmq-server#2363
2020-06-04 04:56:08 +03:00
Michael Klishin 0629da37ad Improve reporting of 'ctl clear_permissions' failures
Part of rabbitmq/rabbitmq-server#2363
2020-06-04 04:36:50 +03:00
Michael Klishin e12df13d66 Improve reporting of 'ctl set_topic_permissions' failures
Part of rabbitmq/rabbitmq-server#2363
2020-06-04 04:11:05 +03:00
Michael Klishin d51de26561 Improve reporting of 'ctl set_permissions' failures
Part of rabbitmq/rabbitmq-server#2363
2020-06-04 03:51:36 +03:00