Skip to content

[Feature flag] Cleanup `audit_event_group_rollup`

What does this MR do and why?

  • This removes a feature that isn't working in production

    • Also adds a migration to asynchronously destroy a now unused index
  • database~~, I am wondering if the down method for the migration should actually be a no-op answered in~~ this thread

database

up
main: == [advisory_lock_connection] object_id: 228700, pg_backend_pid: 75471
main: == 20230615030402 RemoveAuditEventsGroupIndex: migrating ======================
main: == 20230615030402 RemoveAuditEventsGroupIndex: migrated (0.1992s) =============
main: == [advisory_lock_connection] object_id: 228700, pg_backend_pid: 75471

ci: == [advisory_lock_connection] object_id: 228940, pg_backend_pid: 75473
ci: == 20230615030402 RemoveAuditEventsGroupIndex: migrating ======================
ci: == 20230615030402 RemoveAuditEventsGroupIndex: migrated (0.0265s) =============
ci: == [advisory_lock_connection] object_id: 228940, pg_backend_pid: 75473
down
main: == [advisory_lock_connection] object_id: 228460, pg_backend_pid: 72740
main: == 20230615030402 RemoveAuditEventsGroupIndex: reverting ======================
main: -- index_exists?("gitlab_partitions_dynamic.audit_events_000000", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_8a6aadd4f2", :algorithm=>:concurrently})
main:    -> 0.0251s
main: -- index_exists?("gitlab_partitions_dynamic.audit_events_202305", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_571aaf4cf4", :algorithm=>:concurrently})
main:    -> 0.0125s
main: -- index_exists?("gitlab_partitions_dynamic.audit_events_202306", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_f552c91158", :algorithm=>:concurrently})
main:    -> 0.0084s
main: -- index_exists?("gitlab_partitions_dynamic.audit_events_202307", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_65a34d6a7e", :algorithm=>:concurrently})
main:    -> 0.0105s
main: -- index_exists?("gitlab_partitions_dynamic.audit_events_202308", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_51e3c603bf", :algorithm=>:concurrently})
main:    -> 0.0073s
main: -- index_exists?("gitlab_partitions_dynamic.audit_events_202309", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_e3b8298fd8", :algorithm=>:concurrently})
main:    -> 0.0138s
main: -- index_exists?("gitlab_partitions_dynamic.audit_events_202310", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_6626ec41a2", :algorithm=>:concurrently})
main:    -> 0.0081s
main: -- index_exists?("gitlab_partitions_dynamic.audit_events_202311", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_3bc4a62b56", :algorithm=>:concurrently})
main:    -> 0.0148s
main: -- index_exists?("gitlab_partitions_dynamic.audit_events_202312", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_f159bb2f41", :algorithm=>:concurrently})
main:    -> 0.0130s
main: == 20230615030402 RemoveAuditEventsGroupIndex: reverted (0.4162s) =============
main: == [advisory_lock_connection] object_id: 228460, pg_backend_pid: 72740

ci: == [advisory_lock_connection] object_id: 228380, pg_backend_pid: 75028
ci: == 20230615030402 RemoveAuditEventsGroupIndex: reverting ======================
ci: -- index_exists?("gitlab_partitions_dynamic.audit_events_000000", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_8a6aadd4f2", :algorithm=>:concurrently})
ci:    -> 0.0097s
ci: -- index_exists?("gitlab_partitions_dynamic.audit_events_202305", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_571aaf4cf4", :algorithm=>:concurrently})
ci:    -> 0.0024s
ci: -- index_exists?("gitlab_partitions_dynamic.audit_events_202306", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_f552c91158", :algorithm=>:concurrently})
ci:    -> 0.0032s
ci: -- index_exists?("gitlab_partitions_dynamic.audit_events_202307", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_65a34d6a7e", :algorithm=>:concurrently})
ci:    -> 0.0022s
ci: -- index_exists?("gitlab_partitions_dynamic.audit_events_202308", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_51e3c603bf", :algorithm=>:concurrently})
ci:    -> 0.0022s
ci: -- index_exists?("gitlab_partitions_dynamic.audit_events_202309", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_e3b8298fd8", :algorithm=>:concurrently})
ci:    -> 0.0021s
ci: -- index_exists?("gitlab_partitions_dynamic.audit_events_202310", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_6626ec41a2", :algorithm=>:concurrently})
ci:    -> 0.0021s
ci: -- index_exists?("gitlab_partitions_dynamic.audit_events_202311", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_3bc4a62b56", :algorithm=>:concurrently})
ci:    -> 0.0022s
ci: -- index_exists?("gitlab_partitions_dynamic.audit_events_202312", [:entity_id, :entity_type, :created_at, :id], {:name=>"index_f159bb2f41", :algorithm=>:concurrently})
ci:    -> 0.0016s
ci: == 20230615030402 RemoveAuditEventsGroupIndex: reverted (0.1410s) =============
ci: == [advisory_lock_connection] object_id: 228380, pg_backend_pid: 75028

How to set up and validate locally

  1. Have an EE enabled GitLab instance

  2. find a grouo ID for a group you are owner of

  3. This group will need to have some project and group audit events. You can create some from the rails console using FactoryBot:

    # using the admin user
    user = User.find(1); nil
    # flightjs/Flight project
    project = Project.find(7); nil
    # @flightjs group
    group = project.group; nil 
    
    # create audit events
    FactoryBot.create(:project_audit_event, target_project: project, user: user); nil
    2.times { FactoryBot.create(:group_audit_event, target_group: group, user: user) }; nil
  4. Using the group id, make a request to the API

    curl -v \
         --header "PRIVATE-TOKEN: $TOKEN" \
         -H "Content-Type: application/json" \
         -H "Accept: application/json, text/plain, */*" \
         --url "localhost:3000/api/v4/groups/33/audit_events" | json_pp
  5. you should only see Group audit events in the response

    [
     {
        "author_id" : 1,
        "created_at" : "2023-06-01T07:49:01.334Z",
        "details" : {
           "author_email" : "admin@example.com",
           "author_name" : "Jane Doe",
           "change" : "project_creation_level",
           "entity_path" : "flightjs",
           "from" : "",
           "ip_address" : "127.0.0.1",
           "target_details" : "Flightjs",
           "target_id" : 33,
           "target_type" : "Group",
           "to" : "Developers + Maintainers"
        },
        "entity_id" : 33,
        "entity_type" : "Group",
        "id" : 5
     },
     {
        "author_id" : 1,
        "created_at" : "2023-06-01T07:49:01.321Z",
        "details" : {
           "author_email" : "admin@example.com",
           "author_name" : "Jane Doe",
           "change" : "project_creation_level",
           "entity_path" : "flightjs",
           "from" : "",
           "ip_address" : "127.0.0.1",
           "target_details" : "Flightjs",
           "target_id" : 33,
           "target_type" : "Group",
           "to" : "Developers + Maintainers"
        },
        "entity_id" : 33,
        "entity_type" : "Group",
        "id" : 4
     }
    ]

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Related to #415419 (closed)

Edited by Michael Becker

Merge request reports