add more logging on vhost deletion procedure steps

This commit is contained in:
Ayanda Dube 2024-01-11 16:18:13 +02:00 committed by David Ansari
parent b9b6b3da42
commit 4be40ca6e2
3 changed files with 14 additions and 3 deletions

View File

@ -127,7 +127,7 @@ handle_cast({user_deleted, Details}) ->
%% Schedule user entry deletion, allowing time for connections to close
_ = timer:apply_after(?TRACKING_EXECUTION_TIMEOUT, ?MODULE,
delete_tracked_connection_user_entry, [Username]),
rabbit_log_connection:info("Closing all connections from user '~ts' because it's being deleted", [Username]),
rabbit_log_connection:info("Closing all connections for user '~ts' because the user is being deleted", [Username]),
shutdown_tracked_items(
rabbit_connection_tracking:list_of_user(Username),
rabbit_misc:format("user '~ts' is deleted", [Username])).

View File

@ -271,18 +271,23 @@ delete(VHost, ActingUser) ->
%% modules, like `rabbit_amqqueue:delete_all_for_vhost(VHost)'. These new
%% calls would be responsible for the atomicity, not this code.
%% Clear the permissions first to prohibit new incoming connections when deleting a vhost
rabbit_log:info("Clearing permissions in vhost '~ts' because it's being deleted", [VHost]),
_ = rabbit_auth_backend_internal:clear_permissions_for_vhost(VHost, ActingUser),
_ = rabbit_auth_backend_internal:clear_topic_permissions_for_vhost(VHost, ActingUser),
rabbit_log:info("Deleting queues in vhost '~ts' because it's being deleted", [VHost]),
QDelFun = fun (Q) -> rabbit_amqqueue:delete(Q, false, false, ActingUser) end,
[begin
Name = amqqueue:get_name(Q),
assert_benign(rabbit_amqqueue:with(Name, QDelFun), ActingUser)
end || Q <- rabbit_amqqueue:list(VHost)],
rabbit_log:info("Deleting exchanges in vhost '~ts' because it's being deleted", [VHost]),
[assert_benign(rabbit_exchange:delete(Name, false, ActingUser), ActingUser) ||
#exchange{name = Name} <- rabbit_exchange:list(VHost)],
rabbit_log:info("Clearing policies and runtime parameters in vhost '~ts' because it's being deleted", [VHost]),
_ = rabbit_runtime_parameters:clear_vhost(VHost, ActingUser),
_ = [rabbit_policy:delete(VHost, proplists:get_value(name, Info), ActingUser)
|| Info <- rabbit_policy:list(VHost)],
rabbit_log:debug("Removing vhost '~ts' from the metadata storage because it's being deleted", [VHost]),
case rabbit_db_vhost:delete(VHost) of
true ->
ok = rabbit_event:notify(

View File

@ -75,11 +75,17 @@ delete_on_all_nodes(VHost) ->
stop_and_delete_vhost(VHost) ->
StopResult = case lookup_vhost_sup_record(VHost) of
not_found -> ok;
not_found ->
rabbit_log:warning("Supervisor for vhost '~ts' not found during deletion procedure",
[VHost]),
ok;
#vhost_sup{wrapper_pid = WrapperPid,
vhost_sup_pid = VHostSupPid} ->
case is_process_alive(WrapperPid) of
false -> ok;
false ->
rabbit_log:info("Supervisor ~tp for vhost '~ts' already stopped",
[VHostSupPid, VHost]),
ok;
true ->
rabbit_log:info("Stopping vhost supervisor ~tp"
" for vhost '~ts'",