Skip to content
This repository has been archived by the owner on Nov 17, 2020. It is now read-only.

Commit

Permalink
Return Unix error codes in node health check
Browse files Browse the repository at this point in the history
  • Loading branch information
Diana Corbacho committed Feb 26, 2016
1 parent b836528 commit 92ae50e
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/rabbit_health_check.erl
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ node_health_check(Node, is_running) ->
fun(true) ->
true;
(false) ->
throw({node_is_ko, "rabbit application is not running"})
throw({node_is_ko, "rabbit application is not running", 70})
end);
node_health_check(Node, list_channels) ->
node_health_check(
Expand All @@ -51,7 +51,7 @@ node_health_check(Node, list_channels) ->
(Other) ->
ErrorMsg = io_lib:format("list_channels unexpected output: ~p",
[Other]),
throw({node_is_ko, ErrorMsg})
throw({node_is_ko, ErrorMsg, 70})
end);
node_health_check(Node, list_queues) ->
node_health_check(
Expand All @@ -61,7 +61,7 @@ node_health_check(Node, list_queues) ->
(Other) ->
ErrorMsg = io_lib:format("list_queues unexpected output: ~p",
[Other]),
throw({node_is_ko, ErrorMsg})
throw({node_is_ko, ErrorMsg, 70})
end);
node_health_check(Node, alarms) ->
node_health_check(
Expand All @@ -72,7 +72,7 @@ node_health_check(Node, alarms) ->
true;
Alarms ->
ErrorMsg = io_lib:format("alarms raised ~p", [Alarms]),
throw({node_is_ko, ErrorMsg})
throw({node_is_ko, ErrorMsg, 70})
end
end).

Expand All @@ -82,11 +82,15 @@ node_health_check(Node, {M, F, A}, Fun) ->
ErrorMsg = io_lib:format(
"health check of node ~p fails: timed out (~p ms)",
[Node, ?NODE_HEALTH_CHECK_TIMEOUT]),
throw({node_is_ko, ErrorMsg});
throw({node_is_ko, ErrorMsg, 70});
{badrpc, nodedown} ->
ErrorMsg = io_lib:format(
"health check of node ~p fails: nodedown", [Node]),
throw({node_is_ko, ErrorMsg, 68});
{badrpc, Reason} ->
ErrorMsg = io_lib:format(
"health check of node ~p fails: ~p", [Node, Reason]),
throw({node_is_ko, ErrorMsg});
throw({node_is_ko, ErrorMsg, 70});
Other ->
Fun(Other)
end.
Expand Down

0 comments on commit 92ae50e

Please sign in to comment.