Skip to content
Merged
Show file tree
Hide file tree
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 @@ -76,23 +76,27 @@ run([Name], #{node := Node, vhost := VHost}) ->
undefined ->
try_force_removing(Node, VHost, Name, ActingUser),
{error, rabbit_data_coercion:to_binary(ErrMsg)};
Match ->
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} = Match,
{_, HostingNode} = lists:keyfind(node, 1, Opts),
case rabbit_misc:rpc_call(
HostingNode, rabbit_shovel_util, delete_shovel, [VHost, Name, ActingUser]) of
{badrpc, _} = Error ->
Error;
{error, not_found} ->
try_force_removing(HostingNode, VHost, Name, ActingUser),
{error, rabbit_data_coercion:to_binary(ErrMsg)};
ok ->
_ = try_clearing_runtime_parameter(Node, VHost, Name, ActingUser),
ok
end
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} ->
delete_shovel(ErrMsg, VHost, Name, ActingUser, Opts, Node);
{{_Name, _VHost}, _Type, {_State, Opts}, _Timestamp} ->
delete_shovel(ErrMsg, VHost, Name, ActingUser, Opts, Node)
end
end.

delete_shovel(ErrMsg, VHost, Name, ActingUser, Opts, Node) ->
{_, HostingNode} = lists:keyfind(node, 1, Opts),
case rabbit_misc:rpc_call(
HostingNode, rabbit_shovel_util, delete_shovel, [VHost, Name, ActingUser]) of
{badrpc, _} = Error ->
Error;
{error, not_found} ->
try_force_removing(HostingNode, VHost, Name, ActingUser),
{error, rabbit_data_coercion:to_binary(ErrMsg)};
ok ->
_ = try_clearing_runtime_parameter(Node, VHost, Name, ActingUser),
ok
end.

switches() ->
[].

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,20 +62,24 @@ run([Name], #{node := Node, vhost := VHost}) ->
case rabbit_shovel_status:find_matching_shovel(VHost, Name, Xs) of
undefined ->
{error, rabbit_data_coercion:to_binary(ErrMsg)};
Match ->
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} = Match,
{_, HostingNode} = lists:keyfind(node, 1, Opts),
case rabbit_misc:rpc_call(
HostingNode, rabbit_shovel_util, restart_shovel, [VHost, Name]) of
{badrpc, _} = Error ->
Error;
{error, not_found} ->
{error, rabbit_data_coercion:to_binary(ErrMsg)};
ok -> ok
end
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} ->
restart_shovel(ErrMsg, Name, VHost, Opts);
{{_Name, _VHost}, _Type, {_State, Opts}, _Timestamp} ->
restart_shovel(ErrMsg, Name, VHost, Opts)
end
end.

restart_shovel(ErrMsg, Name, VHost, Opts) ->
{_, HostingNode} = lists:keyfind(node, 1, Opts),
case rabbit_misc:rpc_call(
HostingNode, rabbit_shovel_util, restart_shovel, [VHost, Name]) of
{badrpc, _} = Error ->
Error;
{error, not_found} ->
{error, rabbit_data_coercion:to_binary(ErrMsg)};
ok -> ok
end.

output(Output, _Opts) ->
'Elixir.RabbitMQ.CLI.DefaultOutput':output(Output).

Expand Down
4 changes: 3 additions & 1 deletion deps/rabbitmq_shovel/src/rabbit_shovel_status.erl
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
pending := rabbit_types:option(non_neg_integer()),
forwarded := rabbit_types:option(non_neg_integer())
} | #{}.
-type status_tuple() :: {name(), type(), info(), metrics(), calendar:datetime()}.
-type status_tuple_41x() :: {name(), type(), info(), metrics(), calendar:datetime()}.
-type status_tuple_40x_and_older() :: {name(), type(), info(), calendar:datetime()}.
-type status_tuple() :: status_tuple_41x() | status_tuple_40x_and_older().

-export_type([info/0, blocked_status/0, shovel_status/0, metrics/0]).

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ status(Node) ->
end.

format(Node, {Name, Type, Info, _Metrics, TS}) ->
[{node, Node}, {timestamp, format_ts(TS)}] ++
format_name(Type, Name) ++
format_info(Info);
format(Node, {Name, Type, Info, TS}) ->
[{node, Node}, {timestamp, format_ts(TS)}] ++
format_name(Type, Name) ++
format_info(Info).
Expand Down