Skip to content

Commit c9697a6

Browse files
committed
Shovels: make changes to shovel status backward compatible
1 parent 33a6a20 commit c9697a6

File tree

4 files changed

+17
-15
lines changed

4 files changed

+17
-15
lines changed

deps/rabbitmq_shovel/src/Elixir.RabbitMQ.CLI.Ctl.Commands.DeleteShovelCommand.erl

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,9 @@ run([Name], #{node := Node, vhost := VHost, force := Force}) ->
8080
undefined ->
8181
try_force_removing(Node, VHost, Name, ActingUser),
8282
{error, rabbit_data_coercion:to_binary(ErrMsg)};
83-
{{_Name, _VHost}, _Type, {terminated, _}, _Metrics, _Timestamp} ->
84-
delete_shovel(ErrMsg, VHost, Name, ActingUser, Node, Node);
85-
{{_Name, _VHost}, _Type, {terminated, Opts, _}, _Metrics, _Timestamp} ->
86-
HostingNode = proplists:get_value(node, Opts, Node),
87-
delete_shovel(ErrMsg, VHost, Name, ActingUser, HostingNode, Node);
8883
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} ->
8984
HostingNode = proplists:get_value(node, Opts, Node),
9085
delete_shovel(ErrMsg, VHost, Name, ActingUser, HostingNode, Node);
91-
{{_Name, _VHost}, _Type, {terminated, _}, _Timestamp} ->
92-
delete_shovel(ErrMsg, VHost, Name, ActingUser, Node, Node);
9386
{{_Name, _VHost}, _Type, {_State, Opts}, _Timestamp} ->
9487
HostingNode = proplists:get_value(node, Opts, Node),
9588
delete_shovel(ErrMsg, VHost, Name, ActingUser, HostingNode, Node)

deps/rabbitmq_shovel/src/Elixir.RabbitMQ.CLI.Ctl.Commands.RestartShovelCommand.erl

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -62,17 +62,16 @@ run([Name], #{node := Node, vhost := VHost}) ->
6262
case rabbit_shovel_status:find_matching_shovel(VHost, Name, Xs) of
6363
undefined ->
6464
{error, rabbit_data_coercion:to_binary(ErrMsg)};
65-
{{_Name, _VHost}, _Type, {terminated, Opts, _}, _Metrics, _Timestamp} ->
66-
restart_shovel(ErrMsg, Name, VHost, Opts);
6765
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} ->
68-
restart_shovel(ErrMsg, Name, VHost, Opts);
66+
HostingNode = proplists:get_value(node, Opts, Node),
67+
restart_shovel(ErrMsg, Name, VHost, HostingNode);
6968
{{_Name, _VHost}, _Type, {_State, Opts}, _Timestamp} ->
70-
restart_shovel(ErrMsg, Name, VHost, Opts)
69+
HostingNode = proplists:get_value(node, Opts, Node),
70+
restart_shovel(ErrMsg, Name, VHost, HostingNode)
7171
end
7272
end.
7373

74-
restart_shovel(ErrMsg, Name, VHost, Opts) ->
75-
{_, HostingNode} = lists:keyfind(node, 1, Opts),
74+
restart_shovel(ErrMsg, Name, VHost, HostingNode) ->
7675
case rabbit_misc:rpc_call(
7776
HostingNode, rabbit_shovel_util, restart_shovel, [VHost, Name]) of
7877
{badrpc, _} = Error ->

deps/rabbitmq_shovel/src/rabbit_shovel_status.erl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@
4444
| {terminated, term()}.
4545
-type info_with_node() :: starting
4646
| {running, proplists:proplist()}
47-
| {terminated, proplists:proplist(), term()}.
47+
| {terminated, proplists:proplist()}.
4848
-type blocked_status() :: running | flow | blocked.
4949
-type shovel_status() :: blocked_status() | ignore.
5050

@@ -219,7 +219,8 @@ inject_node_info(Node, Shovels) ->
219219
{Name, Type, {State, Opts}, Metrics, Timestamp};
220220
%% terminated
221221
({Name, Type, {terminated, Reason}, Metrics, Timestamp}) ->
222-
{Name, Type, {terminated, [{node, Node}], Reason}, Metrics, Timestamp};
222+
{Name, Type, {terminated, [{node, Node},
223+
{reason, Reason}]}, Metrics, Timestamp};
223224
%% running
224225
({Name, Type, {State, Opts}, Metrics, Timestamp}) ->
225226
Opts1 = Opts ++ [{node, Node}],

deps/rabbitmq_shovel/test/delete_shovel_command_SUITE.erl

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,15 @@ end_per_group(_Group, Config) ->
6868
rabbit_ct_client_helpers:teardown_steps() ++
6969
rabbit_ct_broker_helpers:teardown_steps()).
7070

71+
init_per_testcase(Testcase, Config) when Testcase == delete_invalid_uri_another_node ->
72+
case rabbit_ct_helpers:is_mixed_versions(Config) of
73+
true ->
74+
%% The code changes to delete shovel are compatible with older versions, however
75+
%% older versions fail to delete invalid shovels
76+
{skip, "not mixed versions compatible"};
77+
false ->
78+
rabbit_ct_helpers:testcase_started(Config, Testcase)
79+
end;
7180
init_per_testcase(Testcase, Config) ->
7281
rabbit_ct_helpers:testcase_started(Config, Testcase).
7382

0 commit comments

Comments
 (0)