Skip to content

Commit 4eda17b

Browse files
committed
RMQ-1263: An attempt to make shovel status tuple handling backwards compatible
1 parent 11546aa commit 4eda17b

File tree

3 files changed

+37
-25
lines changed

3 files changed

+37
-25
lines changed

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

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,27 @@ run([Name], #{node := Node, vhost := VHost}) ->
7676
undefined ->
7777
try_force_removing(Node, VHost, Name, ActingUser),
7878
{error, rabbit_data_coercion:to_binary(ErrMsg)};
79-
Match ->
80-
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} = Match,
81-
{_, HostingNode} = lists:keyfind(node, 1, Opts),
82-
case rabbit_misc:rpc_call(
83-
HostingNode, rabbit_shovel_util, delete_shovel, [VHost, Name, ActingUser]) of
84-
{badrpc, _} = Error ->
85-
Error;
86-
{error, not_found} ->
87-
try_force_removing(HostingNode, VHost, Name, ActingUser),
88-
{error, rabbit_data_coercion:to_binary(ErrMsg)};
89-
ok ->
90-
_ = try_clearing_runtime_parameter(Node, VHost, Name, ActingUser),
91-
ok
92-
end
79+
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} ->
80+
delete_shovel(ErrMsg, VHost, Name, ActingUser, Opts, Node);
81+
{{_Name, _VHost}, _Type, {_State, Opts}, _Timestamp} ->
82+
delete_shovel(ErrMsg, VHost, Name, ActingUser, Opts, Node)
9383
end
9484
end.
9585

86+
delete_shovel(ErrMsg, VHost, Name, ActingUser, Opts, Node) ->
87+
{_, HostingNode} = lists:keyfind(node, 1, Opts),
88+
case rabbit_misc:rpc_call(
89+
HostingNode, rabbit_shovel_util, delete_shovel, [VHost, Name, ActingUser]) of
90+
{badrpc, _} = Error ->
91+
Error;
92+
{error, not_found} ->
93+
try_force_removing(HostingNode, VHost, Name, ActingUser),
94+
{error, rabbit_data_coercion:to_binary(ErrMsg)};
95+
ok ->
96+
_ = try_clearing_runtime_parameter(Node, VHost, Name, ActingUser),
97+
ok
98+
end.
99+
96100
switches() ->
97101
[].
98102

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,24 @@ 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-
Match ->
66-
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} = Match,
67-
{_, HostingNode} = lists:keyfind(node, 1, Opts),
68-
case rabbit_misc:rpc_call(
69-
HostingNode, rabbit_shovel_util, restart_shovel, [VHost, Name]) of
70-
{badrpc, _} = Error ->
71-
Error;
72-
{error, not_found} ->
73-
{error, rabbit_data_coercion:to_binary(ErrMsg)};
74-
ok -> ok
75-
end
65+
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} ->
66+
restart_shovel(ErrMsg, Name, VHost, Opts);
67+
{{_Name, _VHost}, _Type, {_State, Opts}, _Timestamp} ->
68+
restart_shovel(ErrMsg, Name, VHost, Opts)
7669
end
7770
end.
7871

72+
restart_shovel(ErrMsg, Name, VHost, Opts) ->
73+
{_, HostingNode} = lists:keyfind(node, 1, Opts),
74+
case rabbit_misc:rpc_call(
75+
HostingNode, rabbit_shovel_util, restart_shovel, [VHost, Name]) of
76+
{badrpc, _} = Error ->
77+
Error;
78+
{error, not_found} ->
79+
{error, rabbit_data_coercion:to_binary(ErrMsg)};
80+
ok -> ok
81+
end.
82+
7983
output(Output, _Opts) ->
8084
'Elixir.RabbitMQ.CLI.DefaultOutput':output(Output).
8185

deps/rabbitmq_shovel_management/src/rabbit_shovel_mgmt_util.erl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@ status(Node) ->
4343
end.
4444

4545
format(Node, {Name, Type, Info, _Metrics, TS}) ->
46+
[{node, Node}, {timestamp, format_ts(TS)}] ++
47+
format_name(Type, Name) ++
48+
format_info(Info);
49+
format(Node, {Name, Type, Info, TS}) ->
4650
[{node, Node}, {timestamp, format_ts(TS)}] ++
4751
format_name(Type, Name) ++
4852
format_info(Info).

0 commit comments

Comments
 (0)