Skip to content
Snippets Groups Projects
Commit c231fd10 authored by Vijay Hawoldar's avatar Vijay Hawoldar
Browse files

Add logs to dormant member removal worker

In order to provide a better insight into dormant member removals, we
are adding logs to the removal worker
parent ffa0bb9d
No related branches found
No related tags found
1 merge request!181788Add logs to dormant member removal worker
......@@ -61,6 +61,7 @@ def namespaces_requiring_dormant_member_removal(limit = 1)
def remove_dormant_members(namespace)
dormant_period = namespace.namespace_settings.remove_dormant_members_period.days.ago
admin_bot = ::Users::Internal.admin_bot
dormant_count = 0
::GitlabSubscriptions::SeatAssignment.dormant_in_namespace(namespace, dormant_period).find_each do |assignment|
next if namespace.owner_ids.include?(assignment.user_id)
......@@ -68,7 +69,19 @@ def remove_dormant_members(namespace)
::Gitlab::Auth::CurrentUserMode.optionally_run_in_admin_mode(admin_bot) do
::Members::ScheduleDeletionService.new(namespace, assignment.user_id, admin_bot).execute
end
dormant_count += 1
end
log_monitoring_data(namespace.id, dormant_count)
end
def log_monitoring_data(namespace_id, dormant_count)
Gitlab::AppLogger.info(
message: 'Processed dormant member removal',
namespace_id: namespace_id,
dormant_count: dormant_count
)
end
end
end
......@@ -38,6 +38,18 @@
expect { perform_work }.to change { group.namespace_settings.reload.last_dormant_member_review_at }
end
it 'logs monitoring data' do
allow(Gitlab::AppLogger).to receive(:info)
expect(Gitlab::AppLogger).to receive(:info).with(
message: 'Processed dormant member removal',
namespace_id: group.id,
dormant_count: 1
)
perform_work
end
context 'when the dormant member is an owner of the group' do
it 'does not remove the owner' do
group.add_owner(dormant_assignment.user)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment