6
6
7
7
defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsMirrorSyncCriticalCommand do
8
8
@ moduledoc """
9
+ DEPRECATED: this command does nothing in RabbitMQ 4.0 and newer.
10
+
9
11
Exits with a non-zero code if there are classic mirrored queues that don't
10
12
have any in sync mirrors online and would potentially lose data
11
13
if the target node is shut down.
@@ -25,103 +27,29 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsMirrorSyncCriticalCommand do
25
27
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
26
28
27
29
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
59
31
end
60
32
61
- def output ( { :ok , [ ] } , % { formatter: "json" } ) do
33
+ def output ( :ok , % { formatter: "json" } ) do
62
34
{ :ok , % { "result" => "ok" } }
63
35
end
64
36
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" }
101
39
end
102
40
103
41
use RabbitMQ.CLI.DefaultOutput
104
42
105
- def help_section ( ) , do: :observability_and_health_checks
43
+ def help_section ( ) , do: :deprecated
106
44
107
45
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."
110
47
end
111
48
112
49
def usage , do: "check_if_node_is_mirror_sync_critical"
113
50
114
51
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 ."
116
53
end
117
54
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
127
55
end
0 commit comments