66
77defmodule 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.
@@ -15,113 +17,37 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsMirrorSyncCriticalCommand do
1517
1618 @ behaviour RabbitMQ.CLI.CommandBehaviour
1719
18- import RabbitMQ.CLI.Core.Platform , only: [ line_separator: 0 ]
19-
2020 def scopes ( ) , do: [ :diagnostics , :queues ]
2121
2222 use RabbitMQ.CLI.Core.AcceptsDefaultSwitchesAndTimeout
2323 use RabbitMQ.CLI.Core.MergesNoDefaults
2424 use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
2525 use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
2626
27- 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- } }
27+ def run ( [ ] , _opts ) do
28+ :ok
5929 end
6030
61- def output ( { :ok , [ ] } , % { formatter: "json" } ) do
31+ def output ( :ok , % { formatter: "json" } ) do
6232 { :ok , % { "result" => "ok" } }
6333 end
6434
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 ( ) ) }
35+ def output ( :ok , _opts ) do
36+ { :ok , "ok" }
10137 end
10238
10339 use RabbitMQ.CLI.DefaultOutput
10440
105- def help_section ( ) , do: :observability_and_health_checks
41+ def help_section ( ) , do: :deprecated
10642
10743 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)"
44+ "DEPRECATED. Mirrored queues were removed in RabbitMQ 4.0. This command is a no-op."
11045 end
11146
11247 def usage , do: "check_if_node_is_mirror_sync_critical"
11348
114- def banner ( [ ] , % { node: node_name } ) do
115- "Checking if node #{ node_name } is critical for data safety of any classic mirrored queues .. ."
49+ def banner ( [ ] , _ ) do
50+ "This command is DEPRECATED and is a no-op. It will be removed in a future version ."
11651 end
11752
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
12753end
0 commit comments