From 742c41876a713305298a6609dd46af69cb3354ba Mon Sep 17 00:00:00 2001 From: David Ansari Date: Mon, 15 Apr 2024 14:13:50 +0200 Subject: [PATCH] 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. (cherry picked from commit f6d4fc2e72b36dd7353b9644e64b2a8fb5b8fd77) (cherry picked from commit 1f01500d1ba24f5691cc2305536b1a585fa90546) # Conflicts: # deps/rabbitmq_stream/src/rabbit_stream_reader.erl --- .../rabbitmq_stream/src/rabbit_stream_reader.erl | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/deps/rabbitmq_stream/src/rabbit_stream_reader.erl b/deps/rabbitmq_stream/src/rabbit_stream_reader.erl index 9a044b9d6bdf..815b0effc300 100644 --- a/deps/rabbitmq_stream/src/rabbit_stream_reader.erl +++ b/deps/rabbitmq_stream/src/rabbit_stream_reader.erl @@ -1574,6 +1574,7 @@ handle_frame_pre_auth(Transport, send(Transport, S, Frame), %% FIXME check if vhost is alive (see rabbit_reader:is_vhost_alive/2) +<<<<<<< HEAD Connection#stream_connection{connection_step = opened, virtual_host = VirtualHost} catch @@ -1584,6 +1585,21 @@ handle_frame_pre_auth(Transport, #{}}}), send(Transport, S, F), Connection#stream_connection{connection_step = failure} +======= + + {_, Conn} = ensure_token_expiry_timer(User, + Connection#stream_connection{connection_step = opened, + virtual_host = VirtualHost}), + Conn + catch exit:#amqp_error{explanation = Explanation} -> + rabbit_log:warning("Opening connection failed: ~ts", [Explanation]), + F = rabbit_stream_core:frame({response, CorrelationId, + {open, + ?RESPONSE_VHOST_ACCESS_FAILURE, + #{}}}), + send(Transport, S, F), + Connection#stream_connection{connection_step = failure} +>>>>>>> 1f01500d1b (Print more logs when stream connection fails to open) end, {Connection1, State};