Migrate ghost records migrate audit events to Auditor
What does this MR do and why?
This MR refactors audit events in ee/app/services/ee/users/migrate_records_to_ghost_user_service.rb
from using the deprecated AuditEventService.new
to the modern ::Gitlab::Audit::Auditor.audit
pattern.
What this MR changes:
- Replaces
AuditEventService.new
with::Gitlab::Audit::Auditor.audit
in thelog_audit_event
method - Creates a new audit event type configuration
user_records_migrated_to_ghost.yml
- Updates the corresponding test expectations to match the new audit pattern
- Maintains backward compatibility while modernizing the audit event implementation
Why this change is needed:
- Part of the broader initiative to standardize all audit events across GitLab to use the
Auditor
pattern - Improves audit event consistency and maintainability
- Enables better streaming and processing of audit events
- Follows the established patterns for modern audit event implementation
Related Issues
Closes #567635 (closed)
Related to #556329 (closed) - "Ensure all audit events are using Auditor"
Steps to Verify
-
Set up a test environment:
- Create a test user account with some content (issues, merge requests, comments, etc.)
- Ensure you have admin privileges to delete users
-
Delete the user:
- Go to Admin Area → Users
- Find the test user and click on their profile
- Click Delete user
- Choose to delete the user (not hard delete) so the migration service runs
-
Verify audit events are generated:
- Navigate to Admin Area → Monitoring → Audit Events (instance-level)
- Look for audit events with the
user_records_migrated_to_ghost
event type - The event should show details about the user being migrated to ghost user
-
Check the audit event details: The audit event should contain:
- Event type:
user_records_migrated_to_ghost
- Target: The deleted user
- Author: The admin who performed the deletion
- Message indicating the user records were migrated to ghost user
- Additional details including the migration action
- Event type:
Screenshots/Recordings
Edited by Nate Rosandich