From fbc33159e45146ca4783f58aff218d4544bf7496 Mon Sep 17 00:00:00 2001 From: Michael Klishin Date: Fri, 10 Jan 2025 22:04:18 -0500 Subject: [PATCH] HTTP API: make GET /api/aliveness-test a no-op This follows the decision that was made for 'rabbitm-diagnostics node_health_check' which is a no-op as of 4.0.0 following a few years of deprecation. The justification is very similar: 1. There is no such thing as "One True Health Check". A single health check is too coarse-grained to explain what specifically is not right about cluster state 2. Indivual fine-grained health checks have been available for a few years now, see https://www.rabbitmq.com/docs/monitoring#health-checks 3. This particular check tests something that effectively never fails, based on my 14+ years of RabbitMQ contributions and user support of all shapes and forms 4. This check uses a deprecated feature: non-exclusive non-durable/transient classic queues If something about this health check is worth preserving, we can always add a new one under GET /api/health/checks/* Closes #13047. (cherry picked from commit ad906c978678d4ebffee52e2439756648b739033) --- .../src/rabbit_mgmt_wm_aliveness_test.erl | 30 +++---------------- 1 file changed, 4 insertions(+), 26 deletions(-) diff --git a/deps/rabbitmq_management/src/rabbit_mgmt_wm_aliveness_test.erl b/deps/rabbitmq_management/src/rabbit_mgmt_wm_aliveness_test.erl index 92074a1f11e1..c1a59696a0e5 100644 --- a/deps/rabbitmq_management/src/rabbit_mgmt_wm_aliveness_test.erl +++ b/deps/rabbitmq_management/src/rabbit_mgmt_wm_aliveness_test.erl @@ -35,37 +35,15 @@ resource_exists(ReqData, Context) -> end, ReqData, Context}. to_json(ReqData, Context) -> + %% This health check is deprecated and is now a no-op. + %% More specific health checks under GET /api/health/checks/* should be used instead. + %% https://www.rabbitmq.com/docs/monitoring#health-checks rabbit_mgmt_util:with_channel( rabbit_mgmt_util:vhost(ReqData), ReqData, Context, - fun(Ch) -> - #'queue.declare_ok'{queue = ?QUEUE} = amqp_channel:call(Ch, #'queue.declare'{ - queue = ?QUEUE - }), - ok = amqp_channel:call(Ch, #'basic.publish'{routing_key = ?QUEUE}, #amqp_msg{ - payload = <<"test_message">> - }), - case amqp_channel:call(Ch, #'basic.get'{queue = ?QUEUE, no_ack = true}) of - {#'basic.get_ok'{}, _} -> - %% Don't delete the queue. If this is pinged every few - %% seconds we don't want to create a mnesia transaction - %% each time. - rabbit_mgmt_util:reply([{status, ok}], ReqData, Context); - #'basic.get_empty'{} -> - Reason = <<"aliveness-test queue is empty">>, - failure(Reason, ReqData, Context); - Error -> - Reason = rabbit_data_coercion:to_binary(Error), - failure(Reason, ReqData, Context) - end - end + fun(_Ch) -> rabbit_mgmt_util:reply([{status, ok}], ReqData, Context) end ). -failure(Reason, ReqData0, Context0) -> - Body = #{status => failed, reason => Reason}, - {Response, ReqData1, Context1} = rabbit_mgmt_util:reply(Body, ReqData0, Context0), - {stop, cowboy_req:reply(?HEALTH_CHECK_FAILURE_STATUS, #{}, Response, ReqData1), Context1}. - is_authorized(ReqData, Context) -> rabbit_mgmt_util:is_authorized_vhost(ReqData, Context).