Skip to content

Commit 8ef3c34

Browse files
Merge pull request #9982 from rabbitmq/mk-make-intrusive-cli-health-check-a-no-op
Make 'ctl node_health_check' a no-op
2 parents f67058a + 625eded commit 8ef3c34

File tree

2 files changed

+10
-65
lines changed

2 files changed

+10
-65
lines changed

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/node_health_check_command.ex

Lines changed: 8 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9,54 +9,18 @@ defmodule RabbitMQ.CLI.Ctl.Commands.NodeHealthCheckCommand do
99

1010
@behaviour RabbitMQ.CLI.CommandBehaviour
1111

12-
@default_timeout 70_000
13-
1412
def scopes(), do: [:ctl, :diagnostics]
1513
use RabbitMQ.CLI.Core.AcceptsDefaultSwitchesAndTimeout
1614

1715
def merge_defaults(args, opts) do
18-
timeout =
19-
case opts[:timeout] do
20-
nil -> @default_timeout
21-
:infinity -> @default_timeout
22-
other -> other
23-
end
24-
25-
{args, Map.merge(opts, %{timeout: timeout})}
16+
{args, opts}
2617
end
2718

2819
use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
2920
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
3021

31-
def run([], %{node: node_name, timeout: timeout}) do
32-
case :rabbit_misc.rpc_call(node_name, :rabbit_health_check, :node, [node_name, timeout]) do
33-
:ok ->
34-
:ok
35-
36-
true ->
37-
:ok
38-
39-
{:badrpc, _} = err ->
40-
err
41-
42-
{:error_string, error_message} ->
43-
{:healthcheck_failed, error_message}
44-
45-
{:node_is_ko, error_message, _exit_code} ->
46-
{:healthcheck_failed, error_message}
47-
48-
other ->
49-
other
50-
end
51-
end
52-
53-
def output(:ok, _) do
54-
{:ok, "Health check passed"}
55-
end
56-
57-
def output({:healthcheck_failed, message}, _) do
58-
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_software(),
59-
"Error: health check failed. Message: #{message}"}
22+
def run([], _opts) do
23+
:ok
6024
end
6125

6226
use RabbitMQ.CLI.DefaultOutput
@@ -72,17 +36,14 @@ defmodule RabbitMQ.CLI.Ctl.Commands.NodeHealthCheckCommand do
7236
def help_section(), do: :deprecated
7337

7438
def description() do
75-
"DEPRECATED. Performs intrusive, opinionated health checks on a fully booted node. " <>
76-
"See https://www.rabbitmq.com/monitoring.html#health-checks instead"
39+
"DEPRECATED. This command is a no-op. " <>
40+
"See https://www.rabbitmq.com/monitoring.html#health-checks"
7741
end
7842

79-
def banner(_, %{node: node_name, timeout: timeout}) do
43+
def banner(_, _opts) do
8044
[
81-
"This command is DEPRECATED and will be removed in a future version.",
82-
"It performs intrusive, opinionated health checks and requires a fully booted node.",
83-
"Use one of the options covered in https://www.rabbitmq.com/monitoring.html#health-checks instead.",
84-
"Timeout: #{trunc(timeout / 1000)} seconds ...",
85-
"Checking health of node #{node_name} ..."
45+
"This command is DEPRECATED and is a no-op. It will be removed in a future version. ",
46+
"Use one of the options covered in https://www.rabbitmq.com/monitoring.html#health-checks instead."
8647
]
8748
end
8849
end

deps/rabbitmq_cli/test/ctl/node_health_check_command_test.exs

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,11 @@ defmodule NodeHealthCheckCommandTest do
3838
assert @command.validate([], context[:opts]) == :ok
3939
end
4040

41-
test "run: request to a named, active node succeeds", context do
41+
test "run: is a no-op", context do
4242
assert @command.run([], context[:opts])
4343
end
4444

45-
test "run: request to a named, active node with an alarm in effect fails", context do
46-
set_vm_memory_high_watermark(0.0000000000001)
47-
# give VM memory monitor check some time to kick in
48-
:timer.sleep(1500)
49-
{:healthcheck_failed, _message} = @command.run([], context[:opts])
50-
51-
reset_vm_memory_high_watermark()
52-
:timer.sleep(1500)
53-
assert @command.run([], context[:opts]) == :ok
54-
end
55-
56-
test "run: request to a non-existent node returns a badrpc" do
57-
assert match?({:badrpc, _}, @command.run([], %{node: :jake@thedog, timeout: 200}))
58-
end
59-
6045
test "banner", context do
61-
assert @command.banner([], context[:opts]) |> Enum.join("\n") =~ ~r/Checking health/
62-
assert @command.banner([], context[:opts]) |> Enum.join("\n") =~ ~r/#{get_rabbit_hostname()}/
46+
assert @command.banner([], context[:opts]) |> Enum.join("\n") =~ ~r/DEPRECATED/
6347
end
6448
end

0 commit comments

Comments
 (0)