Skip to content

Commit 88c1ad2

Browse files
committed
Adapt to new {error, timeout} return value in Khepri 0.14.0
See rabbitmq/khepri#256.
1 parent e9da930 commit 88c1ad2

File tree

3 files changed

+18
-10
lines changed

3 files changed

+18
-10
lines changed

deps/rabbit/src/rabbit_khepri.erl

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -287,7 +287,9 @@ wait_for_leader(Timeout, Retries) ->
287287
Exists when is_boolean(Exists) ->
288288
rabbit_log:info("Khepri leader elected"),
289289
ok;
290-
{error, {timeout, _ServerId}} ->
290+
{error, timeout} -> %% Khepri >= 0.14.0
291+
wait_for_leader(Timeout, Retries -1);
292+
{error, {timeout, _ServerId}} -> %% Khepri < 0.14.0
291293
wait_for_leader(Timeout, Retries -1);
292294
{error, Reason} ->
293295
throw(Reason)
@@ -491,13 +493,13 @@ remove_down_member(NodeToRemove) ->
491493
[NodeToRemove, ?RA_CLUSTER_NAME, Reason],
492494
#{domain => ?RMQLOG_DOMAIN_GLOBAL}),
493495
Error;
494-
{timeout, _} = Reason ->
496+
{timeout, _LeaderId} ->
495497
?LOG_ERROR(
496498
"Failed to remove remote down node ~s from Khepri "
497-
"cluster \"~s\": ~p",
498-
[NodeToRemove, ?RA_CLUSTER_NAME, Reason],
499+
"cluster \"~s\" due to timeout",
500+
[NodeToRemove, ?RA_CLUSTER_NAME],
499501
#{domain => ?RMQLOG_DOMAIN_GLOBAL}),
500-
{error, Reason}
502+
{error, timeout}
501503
end.
502504

503505
%% @private

deps/rabbit/test/cluster_minority_SUITE.erl

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,27 +187,27 @@ consume_from_queue(Config) ->
187187
amqp_channel:call(Ch, #'basic.consume'{queue = <<"test-queue">>})).
188188

189189
add_vhost(Config) ->
190-
?assertMatch({error, {timeout, _}},
190+
?assertMatch({error, timeout},
191191
rabbit_ct_broker_helpers:add_vhost(Config, <<"vhost1">>)).
192192

193193
update_vhost(Config) ->
194-
?assertThrow({error, {timeout, _}},
194+
?assertThrow({error, timeout},
195195
rabbit_ct_broker_helpers:rpc(Config, 0, rabbit_vhost, update_tags,
196196
[<<"/">>, [carrots], <<"user">>])).
197197

198198
delete_vhost(Config) ->
199199
?assertMatch({'EXIT', _}, rabbit_ct_broker_helpers:delete_vhost(Config, <<"vhost1">>)).
200200

201201
add_user(Config) ->
202-
?assertMatch({error, {timeout, _}},
202+
?assertMatch({error, timeout},
203203
rabbit_ct_broker_helpers:add_user(Config, <<"user1">>)).
204204

205205
update_user(Config) ->
206-
?assertMatch({error, {timeout, _}},
206+
?assertMatch({error, timeout},
207207
rabbit_ct_broker_helpers:set_user_tags(Config, 0, <<"user1">>, [<<"admin">>])).
208208

209209
delete_user(Config) ->
210-
?assertMatch({error, {timeout, _}},
210+
?assertMatch({error, timeout},
211211
rabbit_ct_broker_helpers:delete_user(Config, <<"user1">>)).
212212

213213
set_policy(Config) ->

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,13 @@ 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}, %{node: node_name}) do
72+
# Khepri >= 0.14.0
73+
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_tempfail(), khepri_timeout_error(node_name)}
74+
end
75+
7176
defp format_khepri_output({:error, {:timeout, {:rabbitmq_metadata, _}}}, %{node: node_name}) do
77+
# Khepri < 0.14.0
7278
{:error, RabbitMQ.CLI.Core.ExitCodes.exit_tempfail(), khepri_timeout_error(node_name)}
7379
end
7480

0 commit comments

Comments
 (0)