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.
@@ -15,113 +17,37 @@ defmodule RabbitMQ.CLI.Queues.Commands.CheckIfNodeIsMirrorSyncCriticalCommand do
15
17
16
18
@ behaviour RabbitMQ.CLI.CommandBehaviour
17
19
18
- import RabbitMQ.CLI.Core.Platform , only: [ line_separator: 0 ]
19
-
20
20
def scopes ( ) , do: [ :diagnostics , :queues ]
21
21
22
22
use RabbitMQ.CLI.Core.AcceptsDefaultSwitchesAndTimeout
23
23
use RabbitMQ.CLI.Core.MergesNoDefaults
24
24
use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments
25
25
use RabbitMQ.CLI.Core.RequiresRabbitAppRunning
26
26
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
59
29
end
60
30
61
- def output ( { :ok , [ ] } , % { formatter: "json" } ) do
31
+ def output ( :ok , % { formatter: "json" } ) do
62
32
{ :ok , % { "result" => "ok" } }
63
33
end
64
34
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" }
101
37
end
102
38
103
39
use RabbitMQ.CLI.DefaultOutput
104
40
105
- def help_section ( ) , do: :observability_and_health_checks
41
+ def help_section ( ) , do: :deprecated
106
42
107
43
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."
110
45
end
111
46
112
47
def usage , do: "check_if_node_is_mirror_sync_critical"
113
48
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 ."
116
51
end
117
52
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
53
end
0 commit comments