Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CLI: Finish check_if_any_deprecated_features_are_used implementation (backport #12675) #12734

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading