Skip to content

Commit bc9152d

Browse files
committed
wip
1 parent ef9497e commit bc9152d

File tree

5 files changed

+120
-10
lines changed

5 files changed

+120
-10
lines changed

deps/rabbit/src/rabbit_fifo.erl

+9-4
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,8 @@ state_enter0(leader, #?STATE{consumers = Cons,
811811
{Mod, Fun, Args} ->
812812
[{mod_call, Mod, Fun, Args ++ [Name]} | Effects]
813813
end;
814-
state_enter0(eol, #?STATE{enqueuers = Enqs,
814+
state_enter0(eol, #?STATE{cfg = #cfg{resource = R},
815+
enqueuers = Enqs,
815816
consumers = Cons0,
816817
waiting_consumers = WaitingConsumers0},
817818
Effects) ->
@@ -822,6 +823,8 @@ state_enter0(eol, #?STATE{enqueuers = Enqs,
822823
Acc#{P => V}
823824
end, #{}, WaitingConsumers0),
824825
AllConsumers = maps:merge(Custs, WaitingConsumers1),
826+
rabbit_log:info("EOL ~p", [R]),
827+
rabbit_quorum_queue:rpc_delete_metrics(R),
825828
[{send_msg, P, eol, ra_event}
826829
|| P <- maps:keys(maps:merge(Enqs, AllConsumers))] ++
827830
[{aux, eol}
@@ -836,7 +839,7 @@ tick(Ts, #?STATE{cfg = #cfg{resource = QName}} = State) ->
836839
true ->
837840
[{mod_call, rabbit_quorum_queue, spawn_deleter, [QName]}];
838841
false ->
839-
[{aux, {handle_tick, [QName, overview(State), all_nodes(State)]}}]
842+
[{aux, {handle_tick, [QName, all_nodes(State)]}}]
840843
end.
841844

842845
-spec overview(state()) -> map().
@@ -1029,10 +1032,12 @@ handle_aux(_RaftState, cast, {#return{msg_ids = MsgIds,
10291032
%% for returns with a delivery limit set we can just return as before
10301033
{no_reply, Aux0, RaAux0, [{append, Ret, {notify, Corr, Pid}}]}
10311034
end;
1032-
handle_aux(leader, _, {handle_tick, [QName, MacOverview0, Nodes]},
1035+
handle_aux(leader, _, {handle_tick, [QName, Nodes]},
10331036
#?AUX{tick_pid = Pid} = Aux, RaAux) ->
1037+
RaOverview = ra_aux:overview(RaAux),
1038+
MacOverview0 = maps:get(machine, RaOverview),
10341039
Overview = MacOverview0#{members_info => ra_aux:members_info(RaAux),
1035-
ra_overview => ra_aux:overview(RaAux)},
1040+
ra_overview => maps:remove(machine, RaOverview)},
10361041
NewPid =
10371042
case process_is_alive(Pid) of
10381043
false ->

deps/rabbit/src/rabbit_quorum_queue.erl

+10-1
Original file line numberDiff line numberDiff line change
@@ -1405,6 +1405,7 @@ add_member(Q, Node, Membership, Timeout) when ?amqqueue_is_quorum(Q) ->
14051405
#{condition => {applied, {RaIndex, RaTerm}}}),
14061406
_ = rabbit_amqqueue:update(QName, Fun),
14071407
rabbit_log:info("Added a replica of quorum ~ts on node ~ts", [rabbit_misc:rs(QName), Node]),
1408+
gen_statem:cast(Leader, tick_timeout),
14081409
ok;
14091410
{timeout, _} ->
14101411
_ = ra:force_delete_server(?RA_SYSTEM, ServerId),
@@ -1442,7 +1443,7 @@ delete_member(VHost, Name, Node) ->
14421443

14431444
delete_member(Q, Node) when ?amqqueue_is_quorum(Q) ->
14441445
QName = amqqueue:get_name(Q),
1445-
{RaName, _} = amqqueue:get_pid(Q),
1446+
{RaName, LeaderNode} = amqqueue:get_pid(Q),
14461447
ServerId = {RaName, Node},
14471448
case members(Q) of
14481449
[{_, Node}] ->
@@ -1463,6 +1464,14 @@ delete_member(Q, Node) when ?amqqueue_is_quorum(Q) ->
14631464
end)
14641465
end,
14651466
_ = rabbit_amqqueue:update(QName, Fun),
1467+
1468+
case Node == LeaderNode of
1469+
true ->
1470+
_ = erpc_call(Node, ?MODULE, rpc_delete_metrics,
1471+
[QName], ?RPC_TIMEOUT);
1472+
false ->
1473+
ok
1474+
end,
14661475
case ra:force_delete_server(?RA_SYSTEM, ServerId) of
14671476
ok ->
14681477
rabbit_log:info("Deleted a replica of quorum ~ts on node ~ts", [rabbit_misc:rs(QName), Node]),

deps/rabbitmq_management/priv/www/js/dispatcher.js

+29-1
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,10 @@ dispatcher_add(function(sammy) {
116116
var path = '/queues/' + esc(vhost) + '/' + esc(queue);
117117
var requests = {'queue': {path: path,
118118
options: {ranges:['lengths-q', 'msg-rates-q', 'data-rates-q']}},
119-
'bindings': path + '/bindings'};
119+
'bindings': path + '/bindings',
120+
'nodes': '/nodes?columns=name'
121+
122+
};
120123
// we add extra requests that can be added by code plugged on the extension point
121124
for (var i = 0; i < QUEUE_EXTRA_CONTENT_REQUESTS.length; i++) {
122125
var extra = QUEUE_EXTRA_CONTENT_REQUESTS[i](vhost, queue);
@@ -157,6 +160,31 @@ dispatcher_add(function(sammy) {
157160
$('#action-button').addClass('wait').prop('disabled', true);
158161
return false;
159162
});
163+
sammy.del('#/queues/quorum', function() {
164+
if (this.params['mode'] == 'delete_member') {
165+
if (sync_delete(this, '/queues/quorum/:vhost/:name/replicas/delete')) {
166+
show_popup('info', "Replica deleted");
167+
update();
168+
$('#delete-member-button').addClass('wait').prop('disabled', true);
169+
}
170+
}
171+
return false;
172+
});
173+
sammy.post('#/queues/quorum', function() {
174+
if (this.params['mode'] == 'add_member') {
175+
if (sync_post(this, '/queues/quorum/:vhost/:name/replicas/add')) {
176+
show_popup('info', "Replica added");
177+
$('#action-button').addClass('wait').prop('disabled', true);
178+
update();
179+
}
180+
} else if (this.params['mode'] == 'restart_member') {
181+
if (sync_post(this, '/queues/quorum/:vhost/:name/replicas/restart')) {
182+
show_popup('info', "Member restarted");
183+
update();
184+
}
185+
}
186+
return false;
187+
});
160188
sammy.post('#/bindings', function() {
161189
if (sync_post(this, '/bindings/:vhost/e/:source/:destination_type/:destination'))
162190
update();

deps/rabbitmq_management/priv/www/js/main.js

+4
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,10 @@ function postprocess() {
708708
return confirm("Are you sure? Messages cannot be recovered after purging.");
709709
});
710710

711+
$('form.confirm-quorum-delete-member').on('submit', function() {
712+
return confirm("Are you sure?");
713+
});
714+
711715
$('form.confirm').on('submit', function() {
712716
return confirm("Are you sure? This object cannot be recovered " +
713717
"after deletion.");

deps/rabbitmq_management/priv/www/js/tmpl/queue.ejs

+68-4
Original file line numberDiff line numberDiff line change
@@ -421,13 +421,77 @@
421421
</div>
422422
<% } %>
423423

424-
<% if(is_quorum(queue) && queue.hasOwnProperty('raft')) { %>
424+
<% if (is_quorum(queue) && user_administrator) { %>
425+
<div class="section-hidden">
426+
<h2 class="updatable">Member Management</h2>
427+
<div class="hider updatable">
428+
<table class="list">
429+
<% for(i in nodes) { %>
430+
<% var node = nodes[i].name; %>
431+
<tr>
432+
<td class="c">
433+
<%=fmt_string(node) %>
434+
</td>
435+
<% if (queue.members.includes(node)) { %>
436+
<td class="c">
437+
<form action="#/queues/quorum" method="delete" class="confirm-quorum-delete-member inline-form">
438+
<input type="hidden" name="mode" value="delete_member"/>
439+
<input type="hidden" name="vhost" value="<%= fmt_string(queue.vhost) %>"/>
440+
<input type="hidden" name="name" value="<%= fmt_string(queue.name) %>"/>
441+
<input type="hidden" name="node" value="<%= fmt_string(node) %>"/>
442+
<input id="delete-member-button" type="submit" value="Delete member" />
443+
</form>
444+
</td>
445+
<td class="c">
446+
<form action="#/queues/quorum" method="post">
447+
<input type="hidden" name="mode" value="restart_member"/>
448+
<input type="hidden" name="vhost" value="<%= fmt_string(queue.vhost) %>"/>
449+
<input type="hidden" name="name" value="<%= fmt_string(queue.name) %>"/>
450+
<input type="hidden" name="node" value="<%= fmt_string(node) %>"/>
451+
<input type="submit" value="Restart member" />
452+
</form>
453+
</td>
454+
<% if (queue.leader != node) { %>
455+
<td class="c">
456+
<form action="#/queues/quorum" method="post">
457+
<input type="hidden" name="mode" value="make_leader"/>
458+
<input type="hidden" name="vhost" value="<%= fmt_string(queue.vhost) %>"/>
459+
<input type="hidden" name="name" value="<%= fmt_string(queue.name) %>"/>
460+
<input type="hidden" name="node" value="<%= fmt_string(node) %>"/>
461+
<input type="submit" value="Make leader" />
462+
</form>
463+
</td>
464+
<% } %>
465+
<% } else {%>
466+
<td class="c">
467+
<form action="#/queues/quorum" method="post">
468+
<input type="hidden" name="mode" value="add_member"/>
469+
<input type="hidden" name="vhost" value="<%= fmt_string(queue.vhost) %>"/>
470+
<input type="hidden" name="name" value="<%= fmt_string(queue.name) %>"/>
471+
<input type="hidden" name="node" value="<%= fmt_string(node) %>"/>
472+
<input type="submit" value="Add member" />
473+
</form>
474+
</td>
475+
<td>
476+
</td>
477+
<% } %>
478+
</td>
479+
</tr>
480+
<% } %>
481+
</table>
482+
</div>
483+
</div>
484+
<% } %>
485+
486+
<% if(is_quorum(queue)) { %>
425487
<div class="section-hidden">
426488
<h2 class="updatable">Raft Info (Advanced) </h2>
427489
<div class="hider updatable">
428-
<%= format('quorum-members-info', {'mode': 'queue',
429-
'queue': queue,
430-
'members_info': queue.members_info}) %>
490+
<% if(queue.hasOwnProperty('raft')) { %>
491+
<%= format('quorum-members-info', {'mode': 'queue',
492+
'queue': queue,
493+
'members_info': queue.members_info}) %>
494+
<% } %>
431495
</div>
432496
</div>
433497
<% } %>

0 commit comments

Comments
 (0)