Skip to content

Commit 75eb2dc

Browse files
committed
Format all Khepri timeout errors for ctl commands
1 parent 06ed5a7 commit 75eb2dc

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

deps/rabbitmq_cli/lib/rabbitmq/cli/ctl/commands/reset_command.ex

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,6 @@ defmodule RabbitMQ.CLI.Ctl.Commands.ResetCommand do
2828
RabbitMQ.CLI.DefaultOutput.mnesia_running_error(node_name)}
2929
end
3030

31-
def output({:error, {:timeout, {:metadata_store, _}}}, %{node: node_name}) do
32-
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_tempfail(),
33-
RabbitMQ.CLI.DefaultOutput.khepri_timeout_error(node_name)}
34-
end
35-
3631
use RabbitMQ.CLI.DefaultOutput
3732

3833
def usage, do: "reset"

deps/rabbitmq_cli/lib/rabbitmq/cli/default_output.ex

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ defmodule RabbitMQ.CLI.DefaultOutput do
1717
end
1818

1919
def output(result, opts \\ %{}) do
20-
format_output(normalize_output(result, opts))
20+
format_output(format_khepri_output(normalize_output(result, opts), opts))
2121
end
2222

2323
def mnesia_running_error(node_name) do
@@ -68,6 +68,18 @@ defmodule RabbitMQ.CLI.DefaultOutput do
6868
defp normalize_output({unknown, _} = input, _opts) when is_atom(unknown), do: {:error, input}
6969
defp normalize_output(result, _opts) when not is_atom(result), do: {:ok, result}
7070

71+
defp format_khepri_output({:error, {:timeout, {:metadata_store, _}}}, %{node: node_name}) do
72+
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_tempfail(), khepri_timeout_error(node_name)}
73+
end
74+
75+
defp format_khepri_output({:error, :timeout_waiting_for_leader}, %{node: node_name}) do
76+
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_tempfail(), khepri_timeout_error(node_name)}
77+
end
78+
79+
defp format_khepri_output(result, _opts) do
80+
result
81+
end
82+
7183
defp format_output({:error, _} = result) do
7284
result
7385
end

0 commit comments

Comments
 (0)