Skip to content

Commit 13201b2

Browse files
committed
Shovels: return hosting node in terminated shovel status
Fixes deletion and restart
1 parent 7f1ceb2 commit 13201b2

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,9 @@ run([Name], #{node := Node, vhost := VHost, force := Force}) ->
8282
{error, rabbit_data_coercion:to_binary(ErrMsg)};
8383
{{_Name, _VHost}, _Type, {terminated, _}, _Metrics, _Timestamp} ->
8484
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);
8588
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} ->
8689
HostingNode = proplists:get_value(node, Opts, Node),
8790
delete_shovel(ErrMsg, VHost, Name, ActingUser, HostingNode, Node);

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ 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);
6567
{{_Name, _VHost}, _Type, {_State, Opts}, _Metrics, _Timestamp} ->
6668
restart_shovel(ErrMsg, Name, VHost, Opts);
6769
{{_Name, _VHost}, _Type, {_State, Opts}, _Timestamp} ->

deps/rabbitmq_shovel/src/rabbit_shovel_status.erl

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
-type info() :: starting
4343
| {running, proplists:proplist()}
4444
| {terminated, term()}.
45+
-type info_with_node() :: starting
46+
| {running, proplists:proplist()}
47+
| {terminated, proplists:proplist(), term()}.
4548
-type blocked_status() :: running | flow | blocked.
4649
-type shovel_status() :: blocked_status() | ignore.
4750

@@ -52,7 +55,7 @@
5255
pending := rabbit_types:option(non_neg_integer()),
5356
forwarded := rabbit_types:option(non_neg_integer())
5457
} | #{}.
55-
-type status_tuple_41x() :: {name(), type(), info(), metrics(), calendar:datetime()}.
58+
-type status_tuple_41x() :: {name(), type(), info() | info_with_node(), metrics(), calendar:datetime()}.
5659
-type status_tuple_40x_and_older() :: {name(), type(), info(), calendar:datetime()}.
5760
-type status_tuple() :: status_tuple_41x() | status_tuple_40x_and_older().
5861

@@ -216,7 +219,7 @@ inject_node_info(Node, Shovels) ->
216219
{Name, Type, {State, Opts}, Metrics, Timestamp};
217220
%% terminated
218221
({Name, Type, {terminated, Reason}, Metrics, Timestamp}) ->
219-
{Name, Type, {terminated, Reason}, Metrics, Timestamp};
222+
{Name, Type, {terminated, [{node, Node}], Reason}, Metrics, Timestamp};
220223
%% running
221224
({Name, Type, {State, Opts}, Metrics, Timestamp}) ->
222225
Opts1 = Opts ++ [{node, Node}],

0 commit comments

Comments
 (0)