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
This commit is contained in:
parent
a09383d1e5
commit
9f39f60a3e
|
@ -68,7 +68,6 @@ run([Name], #{node := Node, vhost := VHost, force := Force}) ->
|
|||
true -> ?INTERNAL_USER;
|
||||
false -> 'Elixir.RabbitMQ.CLI.Core.Helpers':cli_acting_user()
|
||||
end,
|
||||
|
||||
case rabbit_misc:rpc_call(Node, rabbit_shovel_status, cluster_status_with_nodes, []) of
|
||||
{badrpc, _} = Error ->
|
||||
Error;
|
||||
|
@ -82,14 +81,15 @@ run([Name], #{node := Node, vhost := VHost, force := Force}) ->
|
|||
try_force_removing(Node, VHost, Name, ActingUser),
|
||||
{error, rabbit_data_coercion:to_binary(ErrMsg)};
|
||||
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} ->
|
||||
delete_shovel(ErrMsg, VHost, Name, ActingUser, Opts, Node);
|
||||
HostingNode = proplists:get_value(node, Opts, Node),
|
||||
delete_shovel(ErrMsg, VHost, Name, ActingUser, HostingNode, Node);
|
||||
{{_Name, _VHost}, _Type, {_State, Opts}, _Timestamp} ->
|
||||
delete_shovel(ErrMsg, VHost, Name, ActingUser, Opts, Node)
|
||||
HostingNode = proplists:get_value(node, Opts, Node),
|
||||
delete_shovel(ErrMsg, VHost, Name, ActingUser, HostingNode, Node)
|
||||
end
|
||||
end.
|
||||
|
||||
delete_shovel(ErrMsg, VHost, Name, ActingUser, Opts, Node) ->
|
||||
{_, HostingNode} = lists:keyfind(node, 1, Opts),
|
||||
delete_shovel(ErrMsg, VHost, Name, ActingUser, HostingNode, Node) ->
|
||||
case rabbit_misc:rpc_call(
|
||||
HostingNode, rabbit_shovel_util, delete_shovel, [VHost, Name, ActingUser]) of
|
||||
{badrpc, _} = Error ->
|
||||
|
|
|
@ -89,7 +89,10 @@ notify_clear(VHost, <<"shovel">>, Name, _Username) ->
|
|||
OpMode = rabbit_shovel_operating_mode:operating_mode(),
|
||||
case OpMode of
|
||||
standard ->
|
||||
rabbit_shovel_dyn_worker_sup_sup:stop_child({VHost, Name});
|
||||
rabbit_shovel_dyn_worker_sup_sup:stop_child({VHost, Name}),
|
||||
%% Only necessary for shovels stuck in a restart loop, as no
|
||||
%% process is running the terminate won't be called
|
||||
rabbit_shovel_status:remove({VHost, Name});
|
||||
_Other ->
|
||||
?LOG_DEBUG("Shovel: ignoring a cleared runtime parameter, operating mode: ~ts", [OpMode])
|
||||
end.
|
||||
|
|
|
@ -82,7 +82,7 @@ handle_cast(init, State = #state{config = Config0}) ->
|
|||
catch E:R ->
|
||||
?LOG_ERROR("Shovel ~ts could not connect to source: ~p ~p",
|
||||
[human_readable_name(maps:get(name, Config0)), E, R]),
|
||||
{stop, shutdown, State}
|
||||
{stop, {shutdown, restart}, State}
|
||||
end;
|
||||
handle_cast(connect_dest, State = #state{config = Config0}) ->
|
||||
try rabbit_shovel_behaviour:connect_dest(Config0) of
|
||||
|
@ -93,7 +93,7 @@ handle_cast(connect_dest, State = #state{config = Config0}) ->
|
|||
catch E:R ->
|
||||
?LOG_ERROR("Shovel ~ts could not connect to destination: ~p ~p",
|
||||
[human_readable_name(maps:get(name, Config0)), E, R]),
|
||||
{stop, shutdown, State}
|
||||
{stop, {shutdown, restart}, State}
|
||||
end;
|
||||
handle_cast(init_shovel, State = #state{config = Config}) ->
|
||||
%% Don't trap exits until we have established connections so that
|
||||
|
|
Loading…
Reference in New Issue