Commit Graph

29213 Commits

Author SHA1 Message Date
dependabot[bot] 262ac2b40d
Bump kotlin.version
Bumps `kotlin.version` from 1.9.23 to 1.9.24.

Updates `org.jetbrains.kotlin:kotlin-test` from 1.9.23 to 1.9.24
- [Release notes](https://github.com/JetBrains/kotlin/releases)
- [Changelog](https://github.com/JetBrains/kotlin/blob/v1.9.24/ChangeLog.md)
- [Commits](https://github.com/JetBrains/kotlin/compare/v1.9.23...v1.9.24)

Updates `org.jetbrains.kotlin:kotlin-maven-allopen` from 1.9.23 to 1.9.24

---
updated-dependencies:
- dependency-name: org.jetbrains.kotlin:kotlin-test
  dependency-type: direct:development
  update-type: version-update:semver-patch
- dependency-name: org.jetbrains.kotlin:kotlin-maven-allopen
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-07 18:39:36 +00:00
Michael Klishin e96d100ef8
Merge pull request #11176 from rabbitmq/rabbitmq-server-11171
Log errors from `ranch:handshake`
2024-05-07 00:55:10 -04:00
Michael Klishin ef3888220a
jose dependency belongs to rabbitmq-components.mk
and not oauth2_client or the OAuth 2 plugin.

Pair: Rin Kuryloski
2024-05-06 12:17:19 -04:00
Luke Bakken 620fff22f1
Log errors from `ranch:handshake`
Fixes #11171

An MQTT user encountered TLS handshake timeouts with their IoT device,
and the actual error from `ssl:handshake` / `ranch:handshake` was not
caught and logged.

At this time, `ranch` uses `exit(normal)` in the case of timeouts, but
that should change in the future
(https://github.com/ninenines/ranch/issues/336)
2024-05-06 08:24:38 -07:00
Marcial Rosales 367dba9189 Format using 4 spaces 2024-05-06 15:48:02 +02:00
Marcial Rosales 562b824e86 Improve formatting 2024-05-06 15:33:02 +02:00
Marcial Rosales e5cfebe0dd Fix test 2024-05-06 15:27:30 +02:00
Marcial Rosales 32e58ce52d Add jose dependency 2024-05-06 15:27:29 +02:00
Marcial Rosales fd895aafb7 Return expires_in or exp depending on whats available 2024-05-06 15:26:33 +02:00
Marcial Rosales e520ae2f52 Add constant 2024-05-06 15:26:33 +02:00
Marcial Rosales 407e9d997c Add function that resolves expiration tine 2024-05-06 15:26:33 +02:00
Marcial Rosales d53957e34a Add token helper functions
Such as those to decode and extract
the expiration time
2024-05-06 15:26:31 +02:00
Simon Unge ca4ead762f rabbit_quorum_queue_periodic_membership_reconciliation:on_node_down should be called even with Khepri as db 2024-05-03 22:07:30 -04:00
Simon Unge ad69f5b506 Changed schema logic 2024-05-03 19:18:21 +00:00
Simon Unge 2e2bbaff33 Added global default queue type config 2024-05-03 18:41:59 +00:00
David Ansari 1ecaaadb32
Merge pull request #10964 from rabbitmq/amqp-parser
4.x: change AMQP on disk message format & speed up the AMQP parser
2024-05-03 14:48:23 +02:00
David Ansari d42e110dc6 Apply PR feedback
See
https://github.com/rabbitmq/rabbitmq-server/pull/10964#discussion_r1588940678
2024-05-03 13:21:18 +02:00
Michael Klishin f2af07c613 This should be logged at debug level
There are two info messages in the same function,
they should be enough.
2024-05-03 01:42:22 -04:00
Michael Klishin fa81df0570
Merge pull request #11152 from rabbitmq/rin/oauth2_client-not-a-plugin
Avoid oauth2_client being reported as a plugin
2024-05-03 01:38:05 -04:00
Rin Kuryloski efdb2f2817 Avoid oauth2_client being reported as a plugin
by making it's dependency on rabbit non-explicit
2024-05-02 15:17:41 +02:00
Rin Kuryloski ea4e301510 Avoid leaking nodes in rabbitmq_mqtt shared_SUITE
Test nodes were not torn down in the inner group mnesia_store
2024-05-02 12:26:27 +02:00
David Ansari c3289689bd Remove unused code 2024-05-02 12:13:02 +02:00
David Ansari 4209f3fa56 Set durable annotation for AMQP messages
This is similar to https://github.com/rabbitmq/rabbitmq-server/pull/11057

What?
For incoming AMQP messages, always set the durable message container annotation.

Why?
Even though defaulting to durable=true when no durable annotation is set, as prior
to this commit, is good enough, explicitly setting the durable annotation makes
the code a bit more future proof and maintainable going forward in 4.0 where we
will rely more on the durable annotation because AMQP 1.0 message headers will
be omitted in classic and quorum queues.

The performance impact of always setting the durable annotation is negligible.
2024-05-02 07:56:00 +00:00
David Ansari b721b1a01b Support maps and lists in AMQP array elements 2024-05-02 07:56:00 +00:00
David Ansari 6018155e9b Add property test for AMQP serializer and parser 2024-05-02 07:56:00 +00:00
David Ansari 9f42e40346 Fix crash when old node receives new AMQP message
Similar to how we convert from mc_amqp to mc_amqpl before
sending to a classic queue or quorum queue process if
feature flag message_containers_store_amqp_v1 is disabled,
we also need to do the same conversion before sending to an MQTT QoS 0
queue on the old node.
2024-05-02 07:56:00 +00:00
David Ansari 6225dc9928 Do not parse entire AMQP body
Prior to this commit the entire amqp-value or amqp-sequence sections
were parsed when converting a message from mc_amqp.
Parsing the entire amqp-value or amqp-sequence section can generate a
huge amount of garbage depending on how large these sections are.

Given that other protocol cannot make use of amqp-value and
amqp-sequence sections anyway, leave them AMQP encoded when converting
from mc_amqp.

In fact prior to this commit, the entire body section was parsed
generating huge amounts of garbage just to subsequently encode it again
in mc_amqpl or mc_mqtt.

The new conversion interface from mc_amqp to other mc_* modules will
either output amqp-data sections or the encoded amqp-value /
amqp-sequence sections.
2024-05-02 07:56:00 +00:00
David Ansari 0697c20d70 Support end-to-end checksums over the bare message
This commit enables client apps to automatically perform end-to-end
checksumming over the bare message (i.e. body + application defined
headers).

This commit allows an app to configure the AMQP client:
* for a sending link to automatically compute CRC-32 or Adler-32
checksums over each bare message including the computed checksum
as a footer annotation, and
* for a receiving link to automatically lookup the expected CRC-32
or Adler-32 checksum in the footer annotation and, if present, check
the received checksum against the actually computed checksum.

The commit comes with the following advantages:
1. Transparent end-to-end checksumming. Although checksumming is
   performed by TCP and RabbitMQ queues using the disk, end-to-end
   checksumming is a level higher up and can therefore detect bit flips
   within RabbitMQ nodes or load balancers and other bit flips that
   went unnoticed.
2. Not only is the body checksummed, but also the properties and
   application-properties sections. This is an advantage over AMQP 0.9.1
   because the AMQP protocol disallows modification of the bare message.
3. This commit is currently used for testing the RabbitMQ AMQP
   implementation, but it shows the feasiblity of how apps could also
   get integrity guarantees of the whole bare message using HMACs or
   signatures.
2024-05-02 07:56:00 +00:00
David Ansari 1d02ea9e55 Fix crashes when message gets dead lettered
Fix crashes when message is originally sent via AMQP and
stored within a classic or quorum queue and subsequently
dead lettered where the dead letter exchange needs access to message
annotations or properties or application-properties.
2024-05-02 07:56:00 +00:00
David Ansari 8040b8f36c Do not store delivery-annotations
as they are only meant to be used from sending to receiving peer
2024-05-02 07:56:00 +00:00
David Ansari e8e9ef32cb Delete unused module rabbit_msg_record 2024-05-02 07:56:00 +00:00
David Ansari eac469a8a2 Change AMQP header durable to true by default
AMQP 3.2.1 defines durable=false to be the default.

However, the same section also mentions:
> If the header section is omitted the receiver MUST assume the appropriate
> default values (or the meaning implied by no value being set) for the
> fields within the header unless other target or node specific defaults
> have otherwise been set.

We want RabbitMQ to be secure by default, hence in RabbitMQ we set
durable=true to be the default.
2024-05-02 07:56:00 +00:00
David Ansari 2e15704104 Maintain footer
Ensure footer gets deliverd to AMQP client as received from AMQP client
when feature flag message_containers_store_amqp_v1 is disabled.

Fixes test
```
bazel test //deps/rabbit:amqp_system_SUITE-mixed  -t- --test_sharding_strategy=disabled --test_env FOCUS="-group [dotnet] -case footer"
```
2024-05-02 07:56:00 +00:00
David Ansari 81709d9745 Fix MQTT QoS
This commit fixes test
```
bazel test //deps/rabbitmq_mqtt:shared_SUITE-mixed -t- \
    --test_sharding_strategy=disabled --test_env \
    FOCUS="-group [mqtt,v3,cluster_size_3] -case pubsub"
```

Fix some mixed version tests

Assume the AMQP body, especially amqp-value section won't be parsed.
Hence, omit smart conversions from AMQP to MQTT involving the
Payload-Format-Indicator bit.

Fix test

Fix
```
bazel test //deps/amqp10_client:system_SUITE-mixed -t- --test_sharding_strategy=disabled --test_env FOCUS="-group [rabbitmq]
```
2024-05-02 07:56:00 +00:00
David Ansari 0b51b8d39b Introduce feature flag message_containers_store_amqp_v1
Prior to this commit test case
```
bazel test //deps/rabbit:amqp_client_SUITE-mixed -t- \
    --test_sharding_strategy=disabled --test_env \
    FOCUS="-group [cluster_size_3] -case quorum_queue_on_old_node"
```
was failing because `mc_amqp:size(#v1{})` was called on the old node
which doesn't understand the new AMQP on disk message format.

Even though the old 3.13 node never stored mc_amqp messages in classic
or quorum queues,
1. it will either need to understand the new mc_amqp message format, or
2. we should prevent the new format being sent to 3.13. nodes.

In this commit we decide for the 2nd solution.
In `mc:prepare(store, Msg)`, we convert the new mc_amqp format to
mc_amqpl which is guaranteed to be understood by the old node.
Note that `mc:prepare(store, Msg)` is not only stored before actual
storage, but already before the message is sent to the queue process
(which might be hosted by the old node).
The 2nd solution is easier to reason about over the 1st solution
because:
a) We don't have to backport code meant to be for 4.0 to 3.13, and
b) 3.13 is guaranteed to never store mc_amqp messages in classic or
   quorum queues, even in mixed version clusters.

The disadvantage of the 2nd solution is that messages are converted from
mc_amqp to mc_amqpl and back to mc_amqp if there is an AMQP sender and
AMQP receiver. However, this only happens while the new feature flag
is disabled during the rolling upgrade. In a certain sense, this is a
hybrid to how the AMQP 1.0 plugin worked in 3.13: Even though we don't
proxy via AMQP 0.9.1 anymore, we still convert to AMQP 0.9.1 (mc_amqpl)
messages when feature flag message_containers_store_amqp_v1 is disabled.
2024-05-02 07:56:00 +00:00
David Ansari fc7f458f7c Fix tests 2024-05-02 07:56:00 +00:00
David Ansari 2380b850e9 Do not create binaries in parse/1 2024-05-02 07:56:00 +00:00
David Ansari 2ee246c3b4 Fix MQTT -> Stream
and preserve original delivery_mode field
i.e. leave it undefined if it was sent as undefined
2024-05-02 07:56:00 +00:00
David Ansari 312d2af806 Fix AMQP -> MQTT durable conversion 2024-05-02 07:55:59 +00:00
David Ansari 9fbbb4770c Move frequent clauses to the top 2024-05-02 07:55:59 +00:00
David Ansari bfe285445e Remove slow guard tests 2024-05-02 07:55:59 +00:00
David Ansari 4980669502 New mc_amqp state 2024-05-02 07:55:59 +00:00
David Ansari 0a31d7721b Parse until body and return position for bare sections
parse_many is completely optimized
2024-05-02 07:55:59 +00:00
David Ansari cf7a2a0f45 Speed up AMQP parser 2024-05-02 07:55:59 +00:00
David Ansari 5ce7f49f7a Use more efficient maps:from_list 2024-05-02 07:55:59 +00:00
David Ansari 45694c90c0 Reword atoms 2024-05-02 07:55:59 +00:00
Michael Davis 7f85948e6c
rabbit_ldap_seed: Add commented out verbose logging for LDAP operations 2024-05-01 11:19:12 -04:00
Michael Davis 8c5cf257df
rabbit_ldap_seed: Remove 'memberOf' annotation for "peter" seed user
In openldap 2.5, `memberOf` seems to be a read-only annotation. Instead
the LDAPWiki recommends adding the user's name to the member attribute
on the relevant group objects:
<https://ldapwiki.com/wiki/Wiki.jsp?page=MemberOf>

We already do that when setting up the group objects, so this annotation
is safe to remove.
2024-05-01 11:15:59 -04:00
Michael Davis 30ef8fbe19
rabbit_ldap_seed: Assert seed data deletions are benign 2024-05-01 11:15:59 -04:00
Michael Davis 02ed55d214
ldap system_SUITE: Only reset seed data in end_per_group 2024-05-01 11:10:42 -04:00
Michael Davis 710ae55adf
Setup olcBackend in global ldap example config 2024-05-01 10:31:17 -04:00
Rin Kuryloski dc2c3e03fb Switch slapd backend from bdb to mdb
Slapd 2.5 removed bdb, so switching to mdb

Debian bookworm, to which the buildbuddy CI image was recently
updated, installs slapd 2.5
2024-05-01 13:41:49 +02:00
Rin Kuryloski dec3d3eb89 Add rabbitmqctl to rabbitmq_federation PLT_APPS 2024-04-30 11:17:42 +02:00
Michael Klishin 4f7bda2d07
Merge pull request #11065 from rabbitmq/add-remove-member-improvements
Better handle QQ delete member operation when member already removed
2024-04-29 19:20:19 -04:00
Michael Klishin e158a86880
Merge pull request #11066 from rabbitmq/rabbitmq-server-11047-ignore-ebusy
Ignore `ebusy` when deleting a directory
2024-04-29 13:15:07 -04:00
Karl Nilsson 02b62746bc Better handle QQ delete member operation when member already removed 2024-04-29 16:22:44 +01:00
Michael Klishin 6a3d8be11d
Merge pull request #11114 from rabbitmq/rin/fix-make-dialyze
Fix make dialyze for a number of plugins
2024-04-29 11:22:28 -04:00
Michal Kuratczyk c9fcc4d308 Ignore msg_stores in virginity check
msg_stores is a potential mount point and therefore might exist
2024-04-29 11:18:06 -04:00
Michal Kuratczyk c1db65f724 Ignore ebusy when deleting a folder
A folder can be a mount point and the kernel won't allow
deleting a mount point - it will return ebusy

We don't need to check for ebusy when deleting a file
2024-04-29 11:18:06 -04:00
Luke Bakken 84a517249f Ignore `ebusy` when deleting a directory
Reported in https://github.com/rabbitmq/rabbitmq-server/discussions/11047

This error manifests when the quorum directory is its own mount point
2024-04-29 11:18:06 -04:00
Rin Kuryloski 4ffabad4cb Add cowlib to PLT_APPS for some plugins 2024-04-29 16:15:39 +02:00
Rin Kuryloski 9ed6155c0d Add elixir to PLT_APPS for some plugins 2024-04-29 15:23:09 +02:00
Rin Kuryloski 01ff713830 Update PLT_APPS for rabbitmq_prelaunch 2024-04-29 15:01:35 +02:00
Rin Kuryloski 6a9d668def Set PLT_APPS in a number of plugins where it was missing 2024-04-29 14:54:28 +02:00
Michal Kuratczyk a64b7215cd
List shovels on all nodes
Previously `rabbitmqctl list_shovels` would only list
shovels running on the local node (where the command was executed).
For consistency with other commands, such as `list_connections`
it should list all shovels in the cluster.
2024-04-29 13:21:34 +02:00
Rin Kuryloski b636f41ef2 Allow adding rabbitmqctl to PLT_APPS 2024-04-29 12:47:10 +02:00
Loïc Hoguin 9fbc0fbfa4
Merge pull request #11076 from rabbitmq/loic-fix-cq-shared-store-crashes
CQ: Fix shared store crashes
2024-04-29 09:59:27 +02:00
Michael Klishin 97b26a8a3d
Merge pull request #11101 from rabbitmq/md-shovel-status-cleanup
Cleanup shovels deleted from another node
2024-04-26 19:47:10 -04:00
Michael Klishin 2ccf0c978a
Merge pull request #11077 from rabbitmq/md/vhost-notify-deletions
Notify of permission and parameter deletions when deleting a vhost
2024-04-26 19:46:31 -04:00
Michael Davis 4405332132
shovel status cleanup 2024-04-26 09:53:45 -04:00
Loïc Hoguin fcd011f9cf
CQ: Fix shared store crashes
Crashes could happen because compaction would wrongly write
over valid messages, or truncate over valid messages, because
when looking for messages into the files it would encounter
leftover data that made it look like there was a message,
which prompted compaction to not look for the real messages
hidden within.

To avoid this we ensure that there can't be leftover data
as a result of compaction. We get this guarantee by blanking
data in the holes in the file before we start copying messages
closer to the start of the file. This requires us to do a few
more writes but we know that the only data in the files at any
point are valid messages.

Note that it's possible that some of the messages in the files
are no longer referenced; that's OK. We filter them out after
scanning the file.

This was also a good time to merge two almost identical scan
functions, and be more explicit about what messages should be
dropped after scanning the file (the messages no longer in the
ets index and the fan-out messages that ended up re-written in
a more recent file).
2024-04-26 13:03:34 +02:00
David Ansari 3fd1d0aa32 Fix AMQP fragmentation test in CI
```
make -C deps/rabbit ct-amqp_system t=dotnet:fragmentation
```

fails in the new make CI with:
```
amqp_system_SUITE > dotnet > fragmentation
    #1. {error,{{badmatch,{error,134,
                                 "Unhandled exception. Amqp.AmqpException: Invalid frame size:527, maximum frame size:512.\n   at Amqp.Connection.ThrowIfClosed(String operation)\n   at Amqp.Connection.AddSession(Session session)\n   at Amqp.Session..ctor(Connection connection, Begin begin, OnBegin onBegin)\n   at Amqp.Session..ctor(Connection connection)\n   at Program.AmqpClient.connectWithOpen(String uri, Open opn) in /home/runner/work/rabbitmq-server/rabbitmq-server/deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs:line 53\n   at Program.Test.fragmentation(String uri) in /home/runner/work/rabbitmq-server/rabbitmq-server/deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs:line 284\n   at Program.main(String[] argv) in /home/runner/work/rabbitmq-server/rabbitmq-server/deps/rabbit/test/amqp_system_SUITE_data/fsharp-tests/Program.fs:line 533\n"}},
                [{amqp_system_SUITE,run_dotnet_test,2,
                                    [{file,"amqp_system_SUITE.erl"},
                                     {line,228}]},
                 {test_server,ts_tc,3,[{file,"test_server.erl"},{line,1793}]},
                 {test_server,run_test_case_eval1,6,
                              [{file,"test_server.erl"},{line,1302}]},
                 {test_server,run_test_case_eval,9,
                              [{file,"test_server.erl"},{line,1234}]}]}}
```

RabbitMQ includes its node name and cluster name in the open frame to
the client. Running this test locally shows an open frame size of 467
bytes.
The suspicion is that the node name and cluster name in CI is longer
causing the open frame from RabbitMQ to the client to exceed the frame size
of 512 bytes.
2024-04-26 11:25:09 +02:00
Michael Davis 39c6093bc2
rabbit_vhost:delete/2: Return no_such_vhost when the vhost isn't deleted
Previously `rabbit_vhost:delete/2` threw this error within
`rabbit_policy:list/2` when the vhost didn't exist. We can return the
value instead so that `rabbitmqctl delete_vhost` behaves the same
between these changes and the branch fork point.

The `rabbit_vhost_sup_sup:delete_on_all_nodes/1` cleanup is idempotent so
we can run all teardown steps for the vhost and return this error
instead. This might be useful if deletion fails for some resources
under the vhost, for example a queue. If the vhost record is gone it
might still be useful to try to clean up the vhost's resources.
2024-04-25 11:21:08 -04:00
Arnaud Cogoluègnes df9fec88e3
Replicate x_jms_topic_table Mnesia table
The x_jms_topic_table Mnesia table must be on all nodes
for messages to be published to JMS topic exchanges
and routed to topic subscribers.

The table used to be only in RAM on one node, so it would
be unavailable when the node was down and empty
when it came back up, losing the state for subscribers
still online because connected to other nodes.

References #9005
2024-04-25 16:38:36 +02:00
Michael Davis f0938312ae
vhost_SUITE: Clean up default limit and policy changes in cases
These changes to the defaults can affect other test cases. In particular
it will affect the time to live and deletion events in the vhost
deletion idempotency case.
2024-04-25 10:26:09 -04:00
Michael Davis 837534df9d
Add vhost name to rabbit_vhost_limit notifications 2024-04-25 10:26:09 -04:00
Michael Davis f90c9d3014
Notify of runtime parameter deletion when deleting a vhost 2024-04-25 10:26:09 -04:00
Michael Davis d8fcfc6761
Notify of permission deletions when deleting a vhost 2024-04-25 10:26:09 -04:00
Michael Klishin 57f9aec052
Merge pull request #11079 from aaron-seo/aaron-seo/add-type-to-list-unresponsive-queues
rabbitmqctl: Add `type` info parameter for `list_unresponsive_queues`
2024-04-24 19:07:25 -04:00
Aaron Seo 652da0ebaa
Add type info_key for list_unresponsive_queues
In the rabbitmqctl docs for list_unresponsive_queues, `type` is listed as
a queueinfoitem parameter, but this is not reflected in the source code.
This  commit adds `type` as a queueinfoitem parameter for list_unresponsive_queues.
2024-04-24 20:11:18 +00:00
Michal Kuratczyk 4f35fdba5a
Speed up stop_app
I noticed that `stop_app` would take over 5 seconds on an empty
node which is strange. I found this gap in the logs:
```
2024-04-18 10:49:04.646450+09:00 [info] <0.599.0> Management plugin: to stop collect_statistics.
2024-04-18 10:49:09.647652+09:00 [debug] <0.247.0> Set stop reason to: normal
```
No point waiting for that stats to stop being emitted when we stop the
node completely. It was added in https://github.com/rabbitmq/rabbitmq-server/commit/0e640da5
to ensure the stats stop when the management_agent gets disabled
2024-04-24 11:16:35 +02:00
Marcial Rosales 68b18d6db7 Update selenium libraries
And use appropriate selenium docker image
based on arch
2024-04-23 14:05:21 +02:00
Marcial Rosales baf253a5c7 Logout from idp only when end_session_endpoint
is available
2024-04-23 12:06:34 +02:00
Michal Kuratczyk 72dc78fd31
Fix accepting input from the CLI (#11060)
Follow-up to https://github.com/rabbitmq/rabbitmq-server/pull/10268.

There were still cases where input was ignored, eg.
`rabbitmq-diagnostics -n node observer`
2024-04-23 08:56:10 +02:00
David Ansari 6e056e5701 Fix failing test
Fix the failing GitHub action Test Authentication/Authorization backends
via mutiple messaging protocols / selenium originally caused by #11023
2024-04-22 17:51:02 +02:00
David Ansari e576dd766a Set durable annotation for MQTT messages
This is a follow up to https://github.com/rabbitmq/rabbitmq-server/pull/11012

 ## What?
For incoming MQTT messages, always set the `durable` message container
annotation.

 ## Why?
Even though defaulting to `durable=true` when no durable annotation is
set, as prior to this commit, is good enough, explicitly setting the
durable annotation makes the code a bit more future proof and
maintainable going forward in 4.0 where we will rely more on the durable
annotation because AMQP 1.0 message headers will be omitted in classic
and quorum queues (see https://github.com/rabbitmq/rabbitmq-server/pull/10964)

For MQTT messages, it's important to know whether the message was
published with QoS 0 or QoS 1 because it affects the QoS for the MQTT
message that will delivered to the MQTT subscriber.

The performance impact of always setting the durable annotation is
negligible.
2024-04-22 17:33:10 +02:00
David Ansari 95c5508060 Provide more descriptive type spec 2024-04-21 11:35:19 +02:00
Rin Kuryloski d32a2a8c15
Merge pull request #11039 from rabbitmq/fixup-rabbit_common-dialyze-make
Fix deps for rabbit_common in make
2024-04-19 10:23:29 +02:00
Michael Klishin c09a931a56
Merge pull request #11035 from rabbitmq/dependabot/maven/deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin/main/org.springframework.boot-spring-boot-starter-parent-3.2.5
Bump org.springframework.boot:spring-boot-starter-parent from 3.2.4 to 3.2.5 in /deps/rabbitmq_auth_backend_http/examples/rabbitmq_auth_backend_spring_boot_kotlin
2024-04-18 17:38:49 -04:00
dependabot[bot] 5275e0f914
Bump org.springframework.boot:spring-boot-starter-parent
Bumps [org.springframework.boot:spring-boot-starter-parent](https://github.com/spring-projects/spring-boot) from 3.2.4 to 3.2.5.
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](https://github.com/spring-projects/spring-boot/compare/v3.2.4...v3.2.5)

---
updated-dependencies:
- dependency-name: org.springframework.boot:spring-boot-starter-parent
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-18 18:33:20 +00:00
dependabot[bot] 944799bd54
Bump org.springframework.boot:spring-boot-starter-parent
Bumps [org.springframework.boot:spring-boot-starter-parent](https://github.com/spring-projects/spring-boot) from 3.2.4 to 3.2.5.
- [Release notes](https://github.com/spring-projects/spring-boot/releases)
- [Commits](https://github.com/spring-projects/spring-boot/compare/v3.2.4...v3.2.5)

---
updated-dependencies:
- dependency-name: org.springframework.boot:spring-boot-starter-parent
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-18 18:26:04 +00:00
Rin Kuryloski ff6713d13d Fix deps for rabbit_common in make
so that dialyze passes
2024-04-18 19:11:01 +02:00
David Ansari bb106ff65c Skip access check on absent will queue
Resolves https://github.com/rabbitmq/rabbitmq-server/discussions/11021

Prior to this commit, an MQTT client that connects to RabbitMQ needed
configure access to its will queue even if the will queue has never
existed. This breaks client apps connecting with either v3 or v4 or with
v5 without making use of the Will-Delay-Interval.

Specifically, in 3.13.0 and 3.13.1 an MQTT client that connects to
RabbitMQ needs unnecessarily configure access to queue
`mqtt-will-<MQTT client ID>`.

This commit only check for configure access, if the queue actually gets
deleted, i.e. if it existed.
2024-04-17 12:50:41 +02:00
GitHub 5892905427 bazel run gazelle 2024-04-17 04:03:13 +00:00
Rin Kuryloski 6d845c570c Add dep_gen_batch_server to rabbitmq-components.mk
Follow up to #11016
2024-04-16 17:39:21 +02:00
Rin Kuryloski 2e940334ac
Merge pull request #11016 from rabbitmq/rin/fixup-dialyze-deps-rabbit
Fix make dialyze for deps/rabbit
2024-04-16 16:49:54 +02:00
Jean-Sébastien Pédron ce9c33a8fb
Merge pull request #10904 from rabbitmq/peer-disc-temporary-nodes-and-inetrc
rabbit_peer_discovery: Pass inetrc config file to temporary hidden node
2024-04-16 15:00:15 +02:00
Rin Kuryloski 837748d7e1 Fix make dialyze for deps/rabbit 2024-04-16 14:07:13 +02:00
Rin Kuryloski 4ec33c8678
Fix some dialyzer build system errors in make (#11014)
* make amqp10_common dialyze green in make

* make rabbitmq_ct_client_helpers dialyze green with make

* fixup rabbitmq_prelaunch path ref

* Cleanup unused dep_* vars

* Fixup xref for rabbitmq_ct_helpers

I could not figure out how to make xref aware of the cli code without
also checking the cli code as well, and reporting additional errors

* remove unused file

* fix make diaylze for rabbitmq_stream_common

* update deps/oauth2_client/Makefile to match Bazel
2024-04-16 13:26:51 +02:00
David Ansari e96125bfd3 Store MQTT messages as non-durable if QoS 0
By default, when the 'durable' message container (mc) annotation is unset,
messages are interpreted to be durable.

Prior to this commit, MQTT messages that were sent with QoS 0 were
stored durably in classic queues.
This commit takes the same approach for mc_mqtt as for mc_amqpl and mc_amqp:
If the message is durable, the durable mc annotation will not be set.
If the message is non-durable, the durable mc annotation will be set to false.
2024-04-16 11:43:58 +02:00
Jean-Sébastien Pédron dbf9dfbfa7
peer_discovery_tmp_hidden_node_SUITE: New testsuite for the temporary hidden node
... used by peer discovery.
2024-04-16 10:19:42 +02:00
Jean-Sébastien Pédron bd2d85fcf6
rabbitmq_ct_helpers: Store SSL certicate password in `Config` 2024-04-16 10:19:42 +02:00
Jean-Sébastien Pédron 27b9027c54
rabbit_peer_discovery: Use alternative connection for the temporary hidden node
[Why]
We want to make sure that the queried remote node doesn't know about the
querying node. That's why we use a temporary hidden node in the first
place.

In fact, it is possible to start the temporary hidden node and
communicate with it using an alternative connection instead of the
regular Erlang distribution. This further ensures that the two RabbitMQ
nodes don't connect to each other while properties are queried.

[How]
We use the `standard_io` alternative connection. We need to use
`peer:call/4` instead of `erpc:call/4` to run code on the temporary
hidden node.

While here, we add assertions to verify that the three node didn't form
a full mesh network at the end of the query code.
2024-04-16 10:19:41 +02:00
Jean-Sébastien Pédron 8425afa4c7
rabbit_peer_discovery: Pass inetrc config file to temporary hidden node
[Why]
As shown in #10728, in an IPv6-only environment, `kernel` name
resolution must be configured through an inetrc file.

The temporary hidden node must be configured exactly like the main node
(and all nodes in the cluster in fact) to allow communication. Thus we
must pass the same inetrc file to that temporary hidden node. This
wasn’t the case before this patch.

[How]
We query the main node’s kernel to see if there is any inetrc file set
and we use the same on the temporary hidden node’s command line.

While here, extract the handling of the `proto_dist` module from the TLS
code. This parameter may be used outside of TLS like this IPv6-only
environment.

V2: Accept `inetrc` filenames as atoms, not only lists. `kernel` seems
    to accept them. This makes a better user experience for users used
    to Bourne shell quoting not knowing that single quotes have a
    special meaning in Erlang.

Fixes #10728.
2024-04-16 10:19:41 +02:00
Jean-Sébastien Pédron 54f5ab5a94
rabbit_peer_discovery: If node selects itself, don't pay attention to "DB ready" state
[Why]
When peer discovery runs on initial boot, the database layer is not
ready when peer discovery is executed. Thus if the node selects itself
as the node to "join", it shouldn't pay attention to the database
readyness otherwise it would wait forever.
2024-04-16 10:19:37 +02:00
Michael Klishin 7b9f2ca253 Update management UI footer links for the new website
and drop a link to Slack, which has too many limitations
in its free version at our scale. Discord is the primary
option now.
2024-04-15 21:03:35 -04:00
Michael Klishin 478419ea67 Update startup banner for the new website
Plus add a new link, to the Upgrading guide,
arguably one of the more important guides we have
today.
2024-04-15 19:56:50 -04:00
Michael Klishin b371ec60e0
Merge pull request #10952 from rabbitmq/refactor_ssl_options
Remove duplicate code that built ssl options
2024-04-15 15:54:11 -04:00
Michael Klishin 22e7f022c0
Merge pull request #10989 from rabbitmq/md/boot-avoid-module-scan
Avoid loading all modules during boot
2024-04-15 12:15:36 -04:00
David Ansari f6d4fc2e72 Print more logs when stream connection fails to open
This commit will print
```
[debug] <0.725.0> Transitioned from tcp_connected to peer_properties_exchanged
[debug] <0.725.0> Transitioned from peer_properties_exchanged to authenticating
[debug] <0.725.0> User 'guest' authenticated successfully by backend rabbit_auth_backend_internal
[debug] <0.725.0> Transitioned from authenticating to authenticated
[debug] <0.725.0> Tuning response 1048576 0
[debug] <0.725.0> Open frame received for fakevhost
[warning] <0.725.0> Opening connection failed: access to vhost 'fakevhost' refused for user 'guest'
[debug] <0.725.0> Transitioned from tuning to failure
[warning] <0.725.0> Closing socket #Port<0.48>. Invalid transition from tuning to failure.
[debug] <0.725.0> rabbit_stream_reader terminating in state 'tuning' with reason 'normal'
```
when the user doesn't have access to the vhost.
2024-04-15 16:02:26 +02:00
Marcial Rosales 7c544ea0a1 Add configuration alias to schema
It was added to the code but not to
the schema
2024-04-15 10:16:53 +02:00
Marcial Rosales 175ee2ccc7 Fix test cases 2024-04-15 10:16:53 +02:00
Marcial Rosales f7e25b4611 Remove duplicate code
that returns an Erlang ssl options
from RabbitMq Configuration
2024-04-15 10:16:53 +02:00
Marcial Rosales e6e7f1aa96 Remove unnecessary function 2024-04-15 10:16:53 +02:00
Marcial Rosales 354df19a66 Remote obsolete function and refactor ssl_option
function so that there is only one function which
provides default ssl options
2024-04-15 10:16:53 +02:00
Michael Davis 21b5c9000a
recent history exchange: Test plugin boot and cleanup steps 2024-04-14 08:32:54 -04:00
Michael Davis 016697ba8e
recent history exchange: Fix mnesia deletion return value
The caller expects this value to either be 'ok' or an error tuple but it
was returning `{atomic,ok}` causing a crash when deactivating this
plugin.
2024-04-14 08:17:18 -04:00
Michael Davis 1b35c3f93a
Prefer erlang:monotonic_time/0 for elapsed time measurements
This is now the recommended way to measure durations with the time API:
<https://www.erlang.org/doc/apps/erts/time_correction#how-to-work-with-the-new-api>
2024-04-13 11:28:13 -04:00
Michael Davis 692b6f6661
Avoid loading all modules during boot
A fairly large chunk of boot time is spent trying to look up modules
that have certain attributes via `Module:module_info(attributes)`.
Executing the builtin `module_info/1` function is very very fast but
only after the module is initially loaded. For any unloaded module,
attempting to execute the function loads the module. Code loading can
be fairly slow with some modules taking around a millisecond
individually, and all code loading is currently done in serial by the
code server.

We use this for `rabbit_boot_step` and `rabbit_feature_flag` attributes
for example and we can't avoid scanning many modules without much larger
breaking changes. When we read those attributes though we only lookup
modules from applications that depend on the `rabbit` app. This saves
quite a lot of work because we avoid most dependencies and builtin
modules from Erlang/OTP that we would never load anyways, for example
the `wx` modules.

We can re-use that function in the management plugin to avoid scanning
most available modules for the `rabbit_mgmt_extension` behaviour. We
also need to stop the `prometheus` dependency from scanning for its
interceptor and collector behaviours on boot. We can do this by setting
explicit empty/default values for the application environment variables
`prometheus` uses as defaults. This is a safe change because we don't
use interceptors and we register all collectors explicitly.

**There is a functional change to the management plugin to be aware
of**: any plugins that use the `rabbit_mgmt_extension` behaviour must
declare a dependency on the `rabbit` application. This is true for all
tier-1 plugins but should be kept in mind for community plugins.

For me locally this reduces single node boot (`bazel run broker`) time
from ~6100ms to ~4300ms.
2024-04-12 13:11:50 -04:00
David Ansari e48b0c5214 Avoid function clause
Avoid following function clause error:
```
[{rabbit_amqp_session,incoming_mgmt_link_transfer,
     [{'v1_0.transfer',
          {uint,0},
          {uint,1},
          {binary,<<0>>},
          {uint,0},
          false,false,undefined,undefined,undefined,undefined,undefined},
      <<0,83,112,192,2,1,65>>,
      {state,
          {cfg,65528,<0.3506.0>,<0.3510.0>,
              {user,<<"guest">>,
                  [administrator],
                  [{rabbit_auth_backend_internal,
                       #Fun<rabbit_auth_backend_internal.3.111050101>}]},
              <<"/">>,1,0,#{},none,<<"127.0.0.1:43416 -> 127.0.0.1:5672">>},
          2,398,4294967292,1600,2147483645,
          {[],[]},
          0,#{},#{},#{},#{},#{},#{},[],[],[],[],
          {rabbit_queue_type,#{}},
          [{{resource,<<"/">>,exchange,<<>>},write},
           {{resource,<<"/">>,queue,
                <<"ResourceListenerTest_publisherIsClosedOnExchangeDeletion-aec3-6e1a90386458">>},
            configure}],
          []}],
     [{file,"rabbit_amqp_session.erl"},{line,1694}]},
 {rabbit_amqp_session,handle_control,2,
     [{file,"rabbit_amqp_session.erl"},{line,1068}]},
 {rabbit_amqp_session,handle_cast,2,
     [{file,"rabbit_amqp_session.erl"},{line,391}]},
 {gen_server,try_handle_cast,3,[{file,"gen_server.erl"},{line,1121}]},
 {gen_server,handle_msg,6,[{file,"gen_server.erl"},{line,1183}]},
 {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,241}]}] [condition = amqp:internal-error]
```

when the client keeps sending messages although its target queue got
deleted and the server already sent a DETACH frame to the client.

From now on, the server instead closes the session with session error
amqp:session:unattached-handle

The test case is included in the AMQP Java client.
2024-04-12 11:20:48 +02:00
Michael Klishin e610adaa11
Merge pull request #10908 from cloudamqp/fix/10901-unhandled-function-clause-on-nonexistent-virtual-host
Handle non-existent virtual host in several HTTP API endpoints
2024-04-12 01:41:25 -04:00
markus812498 8392bdeef7 changed log line to allow for MaxConsumer being an integer not a string 2024-04-12 09:42:33 +12:00
Luke Bakken 8ba0562149 No need for `|| exit "$?"`
Follow-up to #10819

@dumbbell made a note that the `|| exit "$?"` code is probably redundant.

@lukebakken tested this patch using the RMQ docker image and `dash`, and
the test procedure provided by @giner here:

https://github.com/rabbitmq/rabbitmq-server/pull/10819#issuecomment-2014141937

```sh
mkdir ~/ubuntu_24.04
vagrant init ubuntu/noble64
cd ~/ubuntu_24.04
vagrant up
vagrant ssh

sudo apt update
sudo apt install docker.io
newgrp docker

mkdir -p /tmp/rabbitmq
cd /tmp/rabbitmq
cat > Dockerfile << 'EOF'
from "rabbitmq"
RUN sed -i 's/wait "\$rabbitmq_server_pid" || true/wait "$rabbitmq_server_pid" || (exit "$?")/g' "$(which rabbitmq-server)"
EOF
docker build -t rabbitmq-test-script .

docker rm -f rabbitmq-orig 2>/dev/null
docker run --restart on-failure -d --name rabbitmq-orig rabbitmq

docker rm -f rabbitmq-test-script 2>/dev/null
docker run --restart on-failure -d --name rabbitmq-test-script rabbitmq-test-script

sleep 5
docker exec rabbitmq-orig /bin/sh -c 'kill -USR2 $(pidof beam.smp)'
docker exec rabbitmq-test-script /bin/sh -c 'kill -USR2 $(pidof beam.smp)'

sleep 5
echo
echo "*** rabbitmq-orig ***"
docker logs rabbitmq-orig 2>&1 | grep "User defined signal\|Starting RabbitMQ"
echo
echo "*** rabbitmq-test-script ***"
docker logs rabbitmq-test-script 2>&1 | grep "User defined signal\|Starting RabbitMQ"
echo
docker ps -a

```
2024-04-11 15:07:37 -04:00
David Ansari 7123492f23 Build map more efficiently
Prefer building the list calling at the end maps:from_list/1 over
building the map element by element.

The 1st approach is chosen in the standard library functions, e.g.
maps:map/2, maps:filter/2, maps:with/2
2024-04-11 09:45:11 +02:00
David Ansari b0260cf4b3 Avoid creation of binaries in AMQP 1.0 generator
When generating iodata() in the AMQP 1.0 generator, prefer integers over
binaries.

Rename functions and variable names to better reflect the AMQP 1.0 spec
instead of using AMQP 0.9.1 wording.
2024-04-10 17:11:34 +02:00
David Ansari 5ad61fe9f3 Fix function_clause when AMQP connection fails
```
make -C deps/rabbit ct-amqp_auth t=address_v2:vhost_absent
```
previously resulted in a function_clause error printing the
following crash report in the client:
```
=ERROR REPORT==== 10-Apr-2024::15:23:39.866688 ===
** State machine <0.207.0> terminating
** Last event = {info,{'DOWN',#Ref<0.1404963469.3720347649.257117>,process,
                              <0.208.0>,normal}}
** When server state  = {open_sent,
                         {state,1,<0.206.0>,
                          #Ref<0.1404963469.3720347649.257117>,<0.209.0>,[],
                          <0.208.0>,
                          {tcp,#Port<0.16>},
                          undefined,undefined,
                          #{notify => <0.204.0>,port => 21000,
                            address => "localhost",
                            sasl =>
                             {plaintext,
                              <<131,104,3,119,5,112,108,97,105,110,109,0,0,0,
                                9,116,101,115,116,32,117,115,101,114,109,0,0,
                                0,9,116,101,115,116,32,117,115,101,114>>},
                            hostname => <<"vhost:this vhost does not exist">>,
                            container_id => <<"my container">>,
                            max_frame_size => 1048576,
                            notify_when_opened => <0.204.0>,
                            notify_when_closed => <0.204.0>,
                            tls_opts => undefined,
                            transfer_limit_margin => 0}}}
** Reason for termination = error:function_clause
** Callback modules = [amqp10_client_connection]
** Callback mode = state_functions
** Stacktrace =
**  [{amqp10_client_connection,open_sent,
         [info,
          {'DOWN',#Ref<0.1404963469.3720347649.257117>,process,<0.208.0>,
              normal},
          {state,1,<0.206.0>,#Ref<0.1404963469.3720347649.257117>,<0.209.0>,
              [],<0.208.0>,
              {tcp,#Port<0.16>},
              undefined,undefined,
              #{notify => <0.204.0>,port => 21000,address => "localhost",
                sasl =>
                    {plaintext,
                        <<131,104,3,119,5,112,108,97,105,110,109,0,0,0,9,116,
                          101,115,116,32,117,115,101,114,109,0,0,0,9,116,101,
                          115,116,32,117,115,101,114>>},
                hostname => <<"vhost:this vhost does not exist">>,
                container_id => <<"my container">>,max_frame_size => 1048576,
                notify_when_opened => <0.204.0>,
                notify_when_closed => <0.204.0>,transfer_limit_margin => 0}}],
         [{file,"amqp10_client_connection.erl"},{line,255}]},
     {gen_statem,loop_state_callback,11,[{file,"gen_statem.erl"},{line,1395}]},
     {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,241}]}]

=CRASH REPORT==== 10-Apr-2024::15:23:39.867521 ===
  crasher:
    initial call: amqp10_client_connection:init/1
    pid: <0.207.0>
    registered_name: []
    exception error: no function clause matching
                     amqp10_client_connection:open_sent(info,
                                                        {'DOWN',
                                                         #Ref<0.1404963469.3720347649.257117>,
                                                         process,<0.208.0>,
                                                         normal},
                                                        {state,1,<0.206.0>,
                                                         #Ref<0.1404963469.3720347649.257117>,
                                                         <0.209.0>,[],
                                                         <0.208.0>,
                                                         {tcp,#Port<0.16>},
                                                         undefined,undefined,
                                                         #{notify => <0.204.0>,
                                                           port => 21000,
                                                           address =>
                                                            "localhost",
                                                           sasl =>
                                                            {plaintext,
                                                             <<131,104,3,119,
                                                               5,112,108,97,
                                                               105,110,109,0,
                                                               0,0,9,116,101,
                                                               115,116,32,117,
                                                               115,101,114,
                                                               109,0,0,0,9,
                                                               116,101,115,
                                                               116,32,117,115,
                                                               101,114>>},
                                                           hostname =>
                                                            <<"vhost:this vhost does not exist">>,
                                                           container_id =>
                                                            <<"my container">>,
                                                           max_frame_size =>
                                                            1048576,
                                                           notify_when_opened =>
                                                            <0.204.0>,
                                                           notify_when_closed =>
                                                            <0.204.0>,
                                                           transfer_limit_margin =>
                                                            0}}) (amqp10_client_connection.erl, line 255)
      in function  gen_statem:loop_state_callback/11 (gen_statem.erl, line 1395)
    ancestors: [<0.206.0>,amqp10_client_sup,<0.182.0>]
    message_queue_len: 0
    messages: []
    links: [<0.206.0>]
    dictionary: []
    trap_exit: true
    status: running
    heap_size: 10958
    stack_size: 28
    reductions: 16408
  neighbours:
```
2024-04-10 16:52:06 +02:00
David Ansari c57ece8207 Extend AMQP message interceptor test 2024-04-10 11:40:49 +02:00
David Ansari 71d1b3b455 Respect message_interceptors.incoming.set_header_timestamp
When feature flag message_containers is enabled, setting
```
message_interceptors.incoming.set_header_timestamp
```
wasn't respected anymore when a message is published via MQTT to a
stream and subsequently consumed via AMQP 0.9.1.

This commit ensures that AMQP 0.9.1 header timestamp_in_ms will be
set.

Note that we must not modify the AMQP 1.0 properties section when messages
are received via AMQP 1.0 and consumed via AMQP 1.0.
Also, message annoation keys not starting with "x-" are reserved.
2024-04-10 11:40:49 +02:00
Lois Soto Lopez 383ddb1634 Use different not_found msg for vhosts & resources
Issue #10901
2024-04-10 11:06:18 +02:00
Stanislav German-Evtushenko 0263b4cdfe Update deps/rabbit/scripts/rabbitmq-server
Co-authored-by: Luke Bakken <lukerbakken@gmail.com>
2024-04-09 14:56:50 -07:00
Stanislav German-Evtushenko c87f0e9c20 Update deps/rabbit/scripts/rabbitmq-server
Co-authored-by: Luke Bakken <lukerbakken@gmail.com>
2024-04-09 14:56:50 -07:00
Stanislav German-Evtushenko a80ebff1bf rabbitmq-server: Propagate exit code
Exit code is useful for monitoring and process supervisors when it comes
to deciding on what to do when the process exits, for example we may
want to restart it or send a report. The current implementation of
`rabbitmq-server` script does not propagate the exit code in a general
case which makes it impossible to know whether the exit was clean and,
for example, use restart policy `on-failure` in docker.

This change makes the exit code to be propagated.
2024-04-09 14:56:50 -07:00
Lois Soto Lopez 0b4fff99af Trigger 404 referencing missing vhost
Issue #10901
2024-04-09 14:30:42 +02:00
Michael Klishin 0172d0406a
Merge pull request #10931 from rabbitmq/rabbitmq-server-10929
Ensure queue data for `members`, etc is sorted upon input
2024-04-08 16:59:47 -04:00
dependabot[bot] 23f3ebf381
Bump com.rabbitmq:amqp-client
Bumps [com.rabbitmq:amqp-client](https://github.com/rabbitmq/rabbitmq-java-client) from 5.20.0 to 5.21.0.
- [Release notes](https://github.com/rabbitmq/rabbitmq-java-client/releases)
- [Commits](https://github.com/rabbitmq/rabbitmq-java-client/compare/v5.20.0...v5.21.0)

---
updated-dependencies:
- dependency-name: com.rabbitmq:amqp-client
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-08 19:00:59 +00:00
Luke Bakken 57ac58f464 Ensure queue data for `members`, etc is sorted upon input
Fixes #10929
2024-04-08 09:15:00 -07:00
Lois Soto Lopez dfddfe3fbb Handle nonexistent vhost on various mgmt endpoints
Before this change some Management API endpoints handling POST requests crashed and returned HTTP 500 error code when called for a non-existing vhost. The reason was that parsing of the virtual host name could return a `not_found` atom which could potentially reach later steps of the data flow, which expect a vhost name binary only. Instead of returning `not_found`, now the code fails early with HTTP 400 error code and a descriptive error reason.

See more details in the github issue
Fixes #10901
2024-04-08 10:14:34 +02:00
Michael Klishin 2c65f43b52
Merge pull request #10916 from rabbitmq/mk-peer-discovery-k8s-improvements
Make more TLS client options configurable for Kubernetes peer discovery
2024-04-07 21:43:58 -04:00
GitHub 77d5d3673b bazel run gazelle 2024-04-06 04:02:19 +00:00
David Ansari 1b75baddd9 Add AMQP 1.0 -> MQTT 5.0 -> AMQP 1.0 test 2024-04-05 15:09:21 +02:00
David Ansari 390d5715a0 Introduce new AMQP 1.0 address format
## What?
Introduce a new address format (let's call it v2) for AMQP 1.0 source and target addresses.

The old format (let's call it v1) is described in
https://github.com/rabbitmq/rabbitmq-server/tree/v3.13.x/deps/rabbitmq_amqp1_0#routing-and-addressing

The only v2 source address format is:
```
/queue/:queue
```

The 4 possible v2 target addresses formats are:
```
/exchange/:exchange/key/:routing-key
/exchange/:exchange
/queue/:queue
<null>
```
where the last AMQP <null> value format requires that each message’s `to` field contains one of:
```
/exchange/:exchange/key/:routing-key
/exchange/:exchange
/queue/:queue
```

 ## Why?

The AMQP address v1 format comes with the following flaws:

1. Obscure address format:

Without reading the documentation, the differences for example between source addresses
```
/amq/queue/:queue
/queue/:queue
:queue
```
are unknown to users. Hence, the address format is obscure.

2. Implicit creation of topologies

Some address formats implicitly create queues (and bindings), such as source address
```
/exchange/:exchange/:binding-key
```
or target address
```
/queue/:queue
```
These queues and bindings are never deleted (by the AMQP 1.0 plugin.)
Implicit creation of such topologies is also obscure.

3. Redundant address formats

```
/queue/:queue
:queue
```
have the same meaning and are therefore redundant.

4. Properties section must be parsed to determine whether a routing key is present

Target address
```
/exchange/:exchange
```
requires RabbitMQ to parse the properties section in order to check whether the message `subject` is set.
If `subject` is not set, the routing key will default to the empty string.

5. Using `subject` as routing key misuses the purpose of this field.

According to the AMQP spec, the message `subject` field's purpose is:
> A common field for summary information about the message content and purpose.

6. Exchange names, queue names and routing keys must not contain the "/" (slash) character.

The current 3.13 implemenation splits by "/" disallowing these
characters in exchange, and queue names, and routing keys which is
unnecessary prohibitive.

7. Clients must create a separate link per target exchange

While this is reasonable working assumption, there might be rare use
cases where it could make sense to create many exchanges (e.g. 1
exchange per queue, see
https://github.com/rabbitmq/rabbitmq-server/discussions/10708) and have
a single application publish to all these exchanges.
With the v1 address format, for an application to send to 500 different
exchanges, it needs to create 500 links.

Due to these disadvantages and thanks to #10559 which allows clients to explicitly create topologies,
we can create a simpler, clearer, and better v2 address format.

 ## How?

 ### Design goals

Following the 7 cons from v1, the design goals for v2 are:
1. The address format should be simple so that users have a chance to
   understand the meaning of the address without necessarily consulting the docs.
2. The address format should not implicitly create queues, bindings, or exchanges.
   Instead, topologies should be created either explicitly via the new management node
   prior to link attachment (see #10559), or in future, we might support the `dynamic`
   source or target properties so that RabbitMQ creates queues dynamically.
3. No redundant address formats.
4. The target address format should explicitly state whether the routing key is present, empty,
   or will be provided dynamically in each message.
5. `Subject` should not be used as routing key. Instead, a better
   fitting field should be used.
6. Exchange names, queue names, and routing keys should allow to contain
   valid UTF-8 encoded data including the "/" character.
7. Allow both target exchange and routing key to by dynamically provided within each message.

Furthermore
8. v2 must co-exist with v1 for at least some time. Applications should be able to upgrade to
   RabbitMQ 4.0 while continuing to use v1. Examples include AMQP 1.0 shovels and plugins communicating
   between a 4.0 and a 3.13 cluster. Starting with 4.1, we should change the AMQP 1.0 shovel and plugin clients
   to use only the new v2 address format. This will allow AMQP 1.0 and plugins to communicate between a 4.1 and 4.2 cluster.
   We will deprecate v1 in 4.0 and remove support for v1 in a later 4.x version.

 ### Additional Context

The address is usually a String, but can be of any type.

The [AMQP Addressing extension](https://docs.oasis-open.org/amqp/addressing/v1.0/addressing-v1.0.html)
suggests that addresses are URIs and are therefore hierarchical and could even contain query parameters:
> An AMQP address is a URI reference as defined by RFC3986.

> the path expression is a sequence of identifier segments that reflects a path through an
> implementation specific relationship graph of AMQP nodes and their termini.
> The path expression MUST resolve to a node’s terminus in an AMQP container.

The [Using the AMQP Anonymous Terminus for Message Routing Version 1.0](https://docs.oasis-open.org/amqp/anonterm/v1.0/cs01/anonterm-v1.0-cs01.html)
extension allows for the target being `null` and the `To` property to contain the node address.
This corresponds to AMQP 0.9.1 where clients can send each message on the same channel to a different `{exchange, routing-key}` destination.

The following v2 address formats will be used.

 ### v2 addresses

A new deprecated feature flag `amqp_address_v1` will be introduced in 4.0 which is permitted by default.
Starting with 4.1, we should change the AMQP 1.0 shovel and plugin AMQP 1.0 clients to use only the new v2 address format.
However, 4.1 server code must still understand the 4.0 AMQP 1.0 shovel and plugin AMQP 1.0 clients’ v1 address format.
The new deprecated feature flag will therefore be denied by default in 4.2.
This allows AMQP 1.0 shovels and plugins to work between
* 4.0 and 3.13 clusters using v1
* 4.1 and 4.0 clusters using v2 from 4.1 to v4.0 and v1 from 4.0 to 4.1
* 4.2 and 4.1 clusters using v2

without having to support both v1 and v2 at the same time in the AMQP 1.0 shovel and plugin clients.
While supporting both v1 and v2 in these clients is feasible, it's simpler to switch the client code directly from v1 to v2.

 ### v2 source addresses

The source address format is
```
/queue/:queue
```
If the deprecated feature flag `amqp_address_v1` is permitted and the queue does not exist, the queue will be auto-created.
If the deprecated feature flag `amqp_address_v1` is denied, the queue must exist.

 ### v2 target addresses

v1 requires attaching a new link for each destination exchange.
v2 will allow dynamic `{exchange, routing-key}` combinations for a given link.
v2 therefore allows for the rare use cases where a single AMQP 1.0 publisher app needs to send to many different exchanges.
Setting up a link per destination exchange could be cumbersome.
Hence, v2 will support the dynamic `{exchange, routing-key}` combinations of AMQP 0.9.1.
To achieve this, we make use of the "Anonymous Terminus for Message Routing" extension:
The target address will contain the AMQP value null.
The `To` field in each message must be set and contain either address format
```
/exchange/:exchange/key/:routing-key
```
or
```
/exchange/:exchange
```
when using the empty routing key.

The `to` field requires an address type and is better suited than the `subject field.

Note that each message will contain this `To` value for the anonymous terminus.
Hence, we should save some bytes being sent across the network and stored on disk.
Using a format
```
/e/:exchange/k/:routing-key
```
saves more bytes, but is too obscure.
However, we use only `/key/` instead of `/routing-key/` so save a few bytes.
This also simplifies the format because users don’t have to remember whether to use spell `routing-key` or `routing_key` or `routingkey`.

The other allowed target address formats are:
```
/exchange/:exchange/key/:routing-key
```
where exchange and routing key are static on the given link.

```
/exchange/:exchange
```
where exchange and routing key are static on the given link, and routing key will be the empty string (useful for example for the fanout exchange).

```
/queue/:queue
```
This provides RabbitMQ beginners the illusion of sending a message directly
to a queue without having to understand what exchanges and routing keys are.
If the deprecated feature flag `amqp_address_v1` is permitted and the queue does not exist, the queue will be auto-created.
If the deprecated feature flag `amqp_address_v1` is denied, the queue must exist.
Besides the additional queue existence check, this queue target is different from
```
/exchange//key/:queue
```
in that queue specific optimisations might be done (in future) by RabbitMQ
(for example different receiving queue types could grant different amounts of link credits to the sending clients).
A write permission check to the amq.default exchange will be performed nevertheless.

v2 will prohibit the v1 static link & dynamic routing-key combination
where the routing key is sent in the message `subject` as that’s also obscure.
For this use case, v2’s new anonymous terminus can be used where both exchange and routing key are defined in the message’s `To` field.

(The bare message must not be modified because it could be signed.)

The alias format
```
/topic/:topic
```
will also be removed.
Sending to topic exchanges is arguably an advanced feature.
Users can directly use the format
```
/exchange/amq.topic/key/:topic
```
which reduces the number of redundant address formats.

 ### v2 address format reference

To sump up (and as stated at the top of this commit message):

The only v2 source address format is:
```
/queue/:queue
```

The 4 possible v2 target addresses formats are:
```
/exchange/:exchange/key/:routing-key
/exchange/:exchange
/queue/:queue
<null>
```
where the last AMQP <null> value format requires that each message’s `to` field contains one of:
```
/exchange/:exchange/key/:routing-key
/exchange/:exchange
/queue/:queue
```

Hence, all 8 listed design goals are reached.
2024-04-05 12:22:02 +02:00
David Ansari dda1c500da Require feature flag message_containers
as it is required for Native AMQP 1.0 in 4.0.

Remove compatibility code.
2024-04-04 15:11:31 +02:00
Michael Klishin 2ea5fc818f Kubernetes peer discovery improvements
* Use file path validators to improve error messages
   when a certificate, key or another file does not
   exist or cannot be read by the node
 * Introduce a number of standard TLS options in
   addition to the Kubelet-provided CA certificate
2024-04-03 22:20:54 -04:00
David Ansari 34862063d0 Skip flaky mixed version test
```
bazel test //deps/rabbit:amqp_client_SUITE-mixed -t- --test_sharding_strategy=disabled --test_env FOCUS="-group [cluster_size_3] -case async_notify_unsettled_classic_queue" --config=rbe-26 --runs_per_test=40
```
was failing 8 out of 40 times.

Skip this test as we know that link flow control with classic queues is
broken in 3.13:
https://github.com/rabbitmq/rabbitmq-server/issues/2597

Credit API v2 in RabbitMQ 4.0 fixes this bug.
2024-04-03 19:14:35 +02:00
David Ansari 2815c71f86 Skip test assertion
Not only are quorum queues wrongly implemented, but also classic queues
when draining in 3.13.

Like quorum queues, classsic queues reply with a send_drained event
before delivering the message(s).

Therefore, we have to skip the drain test in such mixed version
clusters where the leader runs on the old (3.13.1) node.

The new 4.0 implementation with credit API v2 fixes this bug.
2024-04-03 17:51:53 +02:00
David Ansari 65c8456f2c Fix failing mixed version test
Prior to this commit, mixed version test classic_queue_on_old_node
of amqp_client_SUITE was failing.

Commit 02c29ac1c0
must make sure that the new (4.0) AMQP 1.0 classic queue client
continues to convey RabbitMQ internal credit flow control information
back to the old (3.13.1) classic queue server.

Otherwise, the old classic queue server will stop sending more messages
to the new classic queue client after exactly 200 messages, which caused
this mixed version test to fail.
2024-04-03 17:51:53 +02:00
Arnaud Cogoluègnes a81f40966a
Remove stream resource section
Files are no longer available.
2024-04-02 18:09:23 +02:00
Michael Klishin fb05a5124f Cosmetics #10891 2024-04-01 14:34:30 -04:00
tomyouyou 94701c68b4
An exception occurred while declaring a queue, after importing definitions
the version of erlang is erlang-25.3.2.6-1.el8.x86_64.
the version of rabbitmq-server is rabbitmq-server-3.12.10-1.

To reproduce the exception as follows:
1. rabbitmqctl export_definitions def.json
2. rabbitmqctl import_definitions def.json
3. The result of ''rabbit_definitions:list_vhosts()' is:
[root@c1 ssl]#  rabbitmqctl eval 'rabbit_definitions:list_vhosts().'
[#{<<"limits">> => [],
   <<"metadata">> =>
       #{default_queue_type => undefined,
         description => <<"Default virtual host">>,tags => []},
   <<"name">> => <<"/">>}

4. rabbitmqctl export_definitions def.json
5. rabbitmqctl import_definitions def.json
6. The result of ''rabbit_definitions:list_vhosts()' is:
[root@c1 ssl]#  rabbitmqctl eval 'rabbit_definitions:list_vhosts().'
[#{<<"limits">> => [],
   <<"metadata">> =>
       #{default_queue_type => <<"undefined">>,
         description => <<"Default virtual host">>,tags => []},
   <<"name">> => <<"/">>}
7. Declare a queue and an exception will appear, as shown below:
2024-03-29 17:38:09.696 [error] <0.1441.0> ** Generic server <0.1441.0> terminating, ** Last message in was {'$gen_cast', {method, {'queue.declare',0,<<"q12">>,false,false, false,false,false,[]}, none,noflow}}, ** When Server state == {ch, {conf,running,rabbit_framing_amqp_0_9_1,1, <0.1432.0>,<0.1439.0>,<0.1432.0>, <<"10.225.80.5:40388 -> 10.225.80.5:5673">>, undefined, {user,<<"guest">>, [administrator], [{rabbit_auth_backend_internal, #Fun<rabbit_auth_backend_internal.3.2577553>}]}, <<"/">>,<<>>,<0.1433.0>, [{<<"authentication_failure_close">>,bool,true}, {<<"basic.nack">>,bool,true}, {<<"connection.blocked">>,bool,true}, {<<"consumer_cancel_notify">>,bool,true}, {<<"publisher_confirms">>,bool,true}], none,0,134217728,1800000,#{},1000000000,false}, {lstate,<0.1440.0>,false}, none,1, {0,[],[]}, {state,#{},erlang}, #{},#{}, {state,fine,30000, #Ref<0.3663679405.4218945538.136240>}, true,1, {rabbit_confirms,undefined,#{}}, [],[],none,flow,[], {rabbit_queue_type,#{}}, #Ref<0.3663679405.4218945537.194739>,false, {erlang,#Ref<0.3663679405.4218945537.194740>}, "none",false}, ** Reason for termination == , ** {function_clause, [{rabbit_queue_type,discover, [<<"undefined">>], [{file,"rabbit_queue_type.erl"},{line,225}]}, {rabbit_amqqueue,augment_declare_args,5, [{file,"rabbit_amqqueue.erl"},{line,804}]}, {rabbit_channel,handle_method,6, [{file,"rabbit_channel.erl"},{line,2762}]}, {rabbit_channel,handle_method,3, [{file,"rabbit_channel.erl"},{line,1828}]}, {rabbit_channel,handle_cast,2, [{file,"rabbit_channel.erl"},{line,728}]}, {gen_server2,handle_msg,2,[{file,"gen_server2.erl"},{line,1056}]}, {proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,240}]}]},
2024-04-01 15:20:06 +08:00
Michael Klishin 6e7b8d8762
Merge pull request #10875 from Ayanda-D/test-server-10865-and-10870
Tests for rabbitmq-plugins list: --silent and --quiet options
2024-03-28 17:12:43 -04:00