Skip to content

Commit 9f39f60

Browse files
committed
Shovels: fix shovel status and deletion of failed shovels
These shovels are stuck in a restart loop and need to be listed on shovel status, which also allows for its deletion
1 parent a09383d commit 9f39f60

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,6 @@ run([Name], #{node := Node, vhost := VHost, force := Force}) ->
6868
true -> ?INTERNAL_USER;
6969
false -> 'Elixir.RabbitMQ.CLI.Core.Helpers':cli_acting_user()
7070
end,
71-
7271
case rabbit_misc:rpc_call(Node, rabbit_shovel_status, cluster_status_with_nodes, []) of
7372
{badrpc, _} = Error ->
7473
Error;
@@ -82,14 +81,15 @@ run([Name], #{node := Node, vhost := VHost, force := Force}) ->
8281
try_force_removing(Node, VHost, Name, ActingUser),
8382
{error, rabbit_data_coercion:to_binary(ErrMsg)};
8483
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} ->
85-
delete_shovel(ErrMsg, VHost, Name, ActingUser, Opts, Node);
84+
HostingNode = proplists:get_value(node, Opts, Node),
85+
delete_shovel(ErrMsg, VHost, Name, ActingUser, HostingNode, Node);
8686
{{_Name, _VHost}, _Type, {_State, Opts}, _Timestamp} ->
87-
delete_shovel(ErrMsg, VHost, Name, ActingUser, Opts, Node)
87+
HostingNode = proplists:get_value(node, Opts, Node),
88+
delete_shovel(ErrMsg, VHost, Name, ActingUser, HostingNode, Node)
8889
end
8990
end.
9091

91-
delete_shovel(ErrMsg, VHost, Name, ActingUser, Opts, Node) ->
92-
{_, HostingNode} = lists:keyfind(node, 1, Opts),
92+
delete_shovel(ErrMsg, VHost, Name, ActingUser, HostingNode, Node) ->
9393
case rabbit_misc:rpc_call(
9494
HostingNode, rabbit_shovel_util, delete_shovel, [VHost, Name, ActingUser]) of
9595
{badrpc, _} = Error ->

deps/rabbitmq_shovel/src/rabbit_shovel_parameters.erl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,10 @@ notify_clear(VHost, <<"shovel">>, Name, _Username) ->
8989
OpMode = rabbit_shovel_operating_mode:operating_mode(),
9090
case OpMode of
9191
standard ->
92-
rabbit_shovel_dyn_worker_sup_sup:stop_child({VHost, Name});
92+
rabbit_shovel_dyn_worker_sup_sup:stop_child({VHost, Name}),
93+
%% Only necessary for shovels stuck in a restart loop, as no
94+
%% process is running the terminate won't be called
95+
rabbit_shovel_status:remove({VHost, Name});
9396
_Other ->
9497
?LOG_DEBUG("Shovel: ignoring a cleared runtime parameter, operating mode: ~ts", [OpMode])
9598
end.

deps/rabbitmq_shovel/src/rabbit_shovel_worker.erl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ handle_cast(init, State = #state{config = Config0}) ->
8282
catch E:R ->
8383
?LOG_ERROR("Shovel ~ts could not connect to source: ~p ~p",
8484
[human_readable_name(maps:get(name, Config0)), E, R]),
85-
{stop, shutdown, State}
85+
{stop, {shutdown, restart}, State}
8686
end;
8787
handle_cast(connect_dest, State = #state{config = Config0}) ->
8888
try rabbit_shovel_behaviour:connect_dest(Config0) of
@@ -93,7 +93,7 @@ handle_cast(connect_dest, State = #state{config = Config0}) ->
9393
catch E:R ->
9494
?LOG_ERROR("Shovel ~ts could not connect to destination: ~p ~p",
9595
[human_readable_name(maps:get(name, Config0)), E, R]),
96-
{stop, shutdown, State}
96+
{stop, {shutdown, restart}, State}
9797
end;
9898
handle_cast(init_shovel, State = #state{config = Config}) ->
9999
%% Don't trap exits until we have established connections so that

0 commit comments

Comments
 (0)