Skip to content

Commit e1b649c

Browse files
mkuratczykmichaelklishin
authored andcommitted
check_if_node_is_mirror_sync_critical is no-op
Make `check_if_node_is_mirror_sync_critical` a no-op with a deprecation warning. Since this command is commonly used as part of the node shutdown process (eg. by Cluster Operator), making it a no-op instead of removing completly will make the transition to 4.0 easier for users.
1 parent 6b13771 commit e1b649c

File tree

1 file changed

+9
-81
lines changed

1 file changed

+9
-81
lines changed

deps/rabbitmq_cli/lib/rabbitmq/cli/queues/commands/check_if_node_is_mirror_sync_critical_command.ex

Lines changed: 9 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsMirrorSyncCriticalCommand do
88
@moduledoc """
9+
DEPRECATED: this command does nothing in RabbitMQ 4.0 and newer.
10+
911
Exits with a non-zero code if there are classic mirrored queues that don't
1012
have any in sync mirrors online and would potentially lose data
1113
if the target node is shut down.
@@ -25,103 +27,29 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsMirrorSyncCriticalCommand do
2527
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
2628

2729
def run([], %{node: node_name, timeout: timeout}) do
28-
case :rabbit_misc.rpc_call(node_name, :rabbit_nodes, :is_single_node_cluster, [], timeout) do
29-
# if target node is the only one in the cluster, the check makes little sense
30-
# and false positives can be misleading
31-
true ->
32-
{:ok, :single_node_cluster}
33-
34-
false ->
35-
case :rabbit_misc.rpc_call(
36-
node_name,
37-
:rabbit_amqqueue,
38-
:list_local_mirrored_classic_without_synchronised_mirrors_for_cli,
39-
[],
40-
timeout
41-
) do
42-
[] -> {:ok, []}
43-
qs when is_list(qs) -> {:ok, qs}
44-
other -> other
45-
end
46-
47-
other ->
48-
other
49-
end
50-
end
51-
52-
def output({:ok, :single_node_cluster}, %{formatter: "json"}) do
53-
{:ok,
54-
%{
55-
"result" => "ok",
56-
"message" =>
57-
"Target node seems to be the only one in a single node cluster, the check does not apply"
58-
}}
30+
:ok
5931
end
6032

61-
def output({:ok, []}, %{formatter: "json"}) do
33+
def output(:ok, %{formatter: "json"}) do
6234
{:ok, %{"result" => "ok"}}
6335
end
6436

65-
def output({:ok, :single_node_cluster}, %{silent: true}) do
66-
{:ok, :check_passed}
67-
end
68-
69-
def output({:ok, []}, %{silent: true}) do
70-
{:ok, :check_passed}
71-
end
72-
73-
def output({:ok, :single_node_cluster}, %{node: node_name}) do
74-
{:ok,
75-
"Node #{node_name} seems to be the only one in a single node cluster, the check does not apply"}
76-
end
77-
78-
def output({:ok, []}, %{node: node_name}) do
79-
{:ok,
80-
"Node #{node_name} reported no classic mirrored queues without online synchronised mirrors"}
81-
end
82-
83-
def output({:ok, qs}, %{node: node_name, formatter: "json"}) when is_list(qs) do
84-
{:error, :check_failed,
85-
%{
86-
"result" => "error",
87-
"queues" => qs,
88-
"message" =>
89-
"Node #{node_name} reported local classic mirrored queues without online synchronised mirrors"
90-
}}
91-
end
92-
93-
def output({:ok, qs}, %{silent: true}) when is_list(qs) do
94-
{:error, :check_failed}
95-
end
96-
97-
def output({:ok, qs}, %{node: node_name}) when is_list(qs) do
98-
lines = queue_lines(qs, node_name)
99-
100-
{:error, :check_failed, Enum.join(lines, line_separator())}
37+
def output(:ok, %{node: node_name}) do
38+
{:ok, "ok"}
10139
end
10240

10341
use RabbitMQ.CLI.DefaultOutput
10442

105-
def help_section(), do: :observability_and_health_checks
43+
def help_section(), do: :deprecated
10644

10745
def description() do
108-
"Health check that exits with a non-zero code if there are classic mirrored queues " <>
109-
"without online synchronised mirrors (queues that would potentially lose data if the target node is shut down)"
46+
"DEPRECATED. Mirrored queues were removed in RabbitMQ 4.0. This command is a no-op."
11047
end
11148

11249
def usage, do: "check_if_node_is_mirror_sync_critical"
11350

11451
def banner([], %{node: node_name}) do
115-
"Checking if node #{node_name} is critical for data safety of any classic mirrored queues ..."
52+
"This command is DEPRECATED and is a no-op. It will be removed in a future version."
11653
end
11754

118-
#
119-
# Implementation
120-
#
121-
122-
def queue_lines(qs, node_name) do
123-
for q <- qs do
124-
"#{q["readable_name"]} would lose its only synchronised replica (master) if node #{node_name} is stopped"
125-
end
126-
end
12755
end

0 commit comments

Comments
 (0)