From f5fd4588c3271eb83410d8f59347d649af02015c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Date: Wed, 6 Nov 2024 17:45:18 +0100 Subject: [PATCH] CLI: Finish `check_if_any_deprecated_features_are_used` implementation [Why] The previous implementation bypassed the deprecated features subsystem. It only cared about classic mirrored queues and called some queue-related code directly to determine if this specific feature was used. [How] The command code is simplified by calling the deprecated subsystem to list used deprecated features instead. References #12619. (cherry picked from commit ddaea6facb0aad638d22478c3e12f59b0ea2c997) --- ...ny_deprecated_features_are_used_command.ex | 54 +++++++------------ 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_if_any_deprecated_features_are_used_command.ex b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_if_any_deprecated_features_are_used_command.ex index 25463173b66..66e2ef3beab 100644 --- a/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_if_any_deprecated_features_are_used_command.ex +++ b/deps/rabbitmq_cli/lib/rabbitmq/cli/diagnostics/commands/check_if_any_deprecated_features_are_used_command.ex @@ -14,48 +14,30 @@ defmodule RabbitMQ.CLI.Diagnostics.Commands.CheckIfAnyDeprecatedFeaturesAreUsedC use RabbitMQ.CLI.Core.AcceptsNoPositionalArguments use RabbitMQ.CLI.Core.RequiresRabbitAppRunning - def run([], opts) do - are_deprecated_features_used = %{ - :classic_queue_mirroring => is_used_classic_queue_mirroring(opts) - } - - deprecated_features_list = - Enum.reduce( - are_deprecated_features_used, - [], - fn - {_feat, _result}, {:badrpc, _} = acc -> - acc - - {feat, result}, acc -> - case result do - {:badrpc, _} = err -> err - {:error, _} = err -> err - true -> [feat | acc] - false -> acc - end - end - ) + def run([], %{node: node_name, timeout: timeout}) do + deprecated_features_list = :rabbit_misc.rpc_call( + node_name, + :rabbit_deprecated_features, + :list, + [:used], + timeout + ) # health checks return true if they pass case deprecated_features_list do - {:badrpc, _} = err -> err - {:error, _} = err -> err - [] -> true - xs when is_list(xs) -> {false, deprecated_features_list} + {:badrpc, _} = err -> + err + {:error, _} = err -> + err + _ -> + names = Enum.sort(Map.keys(deprecated_features_list)) + case names do + [] -> true + _ -> {false, names} + end end end - def is_used_classic_queue_mirroring(%{node: node_name, timeout: timeout}) do - :rabbit_misc.rpc_call( - node_name, - :rabbit_mirror_queue_misc, - :are_cmqs_used, - [:none], - timeout - ) - end - def output(true, %{formatter: "json"}) do {:ok, %{"result" => "ok"}} end