Skip to content

Commit 3e1fa7b

Browse files
Merge pull request #13888 from rabbitmq/md/scrub-health-check-returns
2 parents 8805cdd + 3f53e01 commit 3e1fa7b

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

deps/rabbitmq_management/src/rabbit_mgmt_wm_health_check_below_node_connection_limit.erl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
-export([to_json/2, content_types_provided/2]).
1212
-export([variances/2]).
1313

14+
-include_lib("kernel/include/logger.hrl").
15+
1416
-include("rabbit_mgmt.hrl").
1517
-include_lib("rabbitmq_management_agent/include/rabbit_mgmt_records.hrl").
1618

@@ -34,16 +36,15 @@ to_json(ReqData, Context) ->
3436
Limit = rabbit_misc:get_env(rabbit, connection_max, infinity),
3537
case ActiveConns < Limit of
3638
true ->
37-
rabbit_mgmt_util:reply(
38-
#{status => ok,
39-
limit => Limit,
40-
connections => ActiveConns}, ReqData, Context);
39+
rabbit_mgmt_util:reply(#{status => ok}, ReqData, Context);
4140
false ->
41+
?LOG_WARNING(
42+
"Node connection limit is reached. Active connections: ~w, "
43+
"limit: ~w",
44+
[ActiveConns, Limit]),
4245
Body = #{
4346
status => failed,
44-
reason => <<"node connection limit is reached">>,
45-
limit => Limit,
46-
connections => ActiveConns
47+
reason => <<"node connection limit is reached">>
4748
},
4849
{Response, ReqData1, Context1} = rabbit_mgmt_util:reply(
4950
Body, ReqData, Context),

deps/rabbitmq_management/src/rabbit_mgmt_wm_health_check_ready_to_serve_clients.erl

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
-export([to_json/2, content_types_provided/2]).
1717
-export([variances/2]).
1818

19+
-include_lib("kernel/include/logger.hrl").
20+
1921
-include("rabbit_mgmt.hrl").
2022
-include_lib("rabbitmq_management_agent/include/rabbit_mgmt_records.hrl").
2123

@@ -33,8 +35,8 @@ content_types_provided(ReqData, Context) ->
3335

3436
to_json(ReqData, Context) ->
3537
case check() of
36-
{ok, Body} ->
37-
rabbit_mgmt_util:reply(Body, ReqData, Context);
38+
ok ->
39+
rabbit_mgmt_util:reply(#{status => ok}, ReqData, Context);
3840
{error, Body} ->
3941
{Response, ReqData1, Context1} = rabbit_mgmt_util:reply(
4042
Body, ReqData, Context),
@@ -62,13 +64,14 @@ check() ->
6264
Limit = rabbit_misc:get_env(rabbit, connection_max, infinity),
6365
case ActiveConns < Limit of
6466
true ->
65-
{ok, #{status => ok,
66-
limit => Limit,
67-
connections => ActiveConns}};
67+
ok;
6868
false ->
69+
?LOG_WARNING(
70+
"Node connection limit is reached. Active "
71+
"connections: ~w, limit: ~w",
72+
[ActiveConns, Limit]),
6973
{error, #{status => failed,
7074
reason => <<"node connection limit is reached">>,
71-
limit => Limit,
7275
connections => ActiveConns}}
7376
end;
7477
[] ->

deps/rabbitmq_management/test/rabbit_mgmt_http_health_checks_SUITE.erl

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -476,8 +476,6 @@ below_node_connection_limit_test(Config) ->
476476
Path = "/health/checks/below-node-connection-limit",
477477
Check0 = http_get(Config, Path, ?OK),
478478
?assertEqual(<<"ok">>, maps:get(status, Check0)),
479-
?assertEqual(0, maps:get(connections, Check0)),
480-
?assertEqual(<<"infinity">>, maps:get(limit, Check0)),
481479

482480
%% Set the connection limit low and open 'limit' connections.
483481
Limit = 10,
@@ -489,8 +487,6 @@ below_node_connection_limit_test(Config) ->
489487

490488
Body0 = http_get_failed(Config, Path),
491489
?assertEqual(<<"failed">>, maps:get(<<"status">>, Body0)),
492-
?assertEqual(10, maps:get(<<"limit">>, Body0)),
493-
?assertEqual(10, maps:get(<<"connections">>, Body0)),
494490

495491
%% Clean up the connections and reset the limit.
496492
[catch rabbit_ct_client_helpers:close_connection(C) || C <- Connections],
@@ -519,8 +515,6 @@ ready_to_serve_clients_test(Config) ->
519515

520516
Body1 = http_get_failed(Config, Path),
521517
?assertEqual(<<"failed">>, maps:get(<<"status">>, Body1)),
522-
?assertEqual(10, maps:get(<<"limit">>, Body1)),
523-
?assertEqual(10, maps:get(<<"connections">>, Body1)),
524518

525519
%% Clean up the connections and reset the limit.
526520
[catch rabbit_ct_client_helpers:close_connection(C) || C <- Connections],

0 commit comments

Comments
 (0)