Duplicate audit event on project creation from template
Summary
When project is created using built-in/custom template, two audit events are created.
Steps to reproduce
- Login as a user with developer/maintainer permission and create a new project
- Follow instruction laid out in https://docs.gitlab.com/ee/gitlab-basics/create-project.html#built-in-templates to create a new project
- Navigate to Admin Area > Monitoring > Audit Log
- Observe two duplicate entries (i.e.
Added project
)
Example Project
(If possible, please create an example project here on GitLab.com that exhibits the problematic behavior, and link to it here in the bug report)
(If you are using an older version of GitLab, this will also determine whether the bug is fixed in a more recent version)
What is the current bug behavior?
Two duplicate audit events when project created with templates.
What is the expected correct behavior?
There should be only 1 audit event recorded.
Relevant logs and/or screenshots
grep -ir iCv1CEjqcG3 log/audit_json.log
log/audit_json.log:{"severity":"INFO","time":"2020-03-11T01:04:12.891Z","correlation_id":"iCv1CEjqcG3","author_id":1,"entity_id":10,"entity_type":"Project","add":"project","author_name":"Harry Potter","target_id":"root/tanuki-rails","target_type":"Project","target_details":"root/tanuki-rails","ip_address":"127.0.0.1","entity_path":"root/tanuki-rails"}
log/audit_json.log:{"severity":"INFO","time":"2020-03-11T01:04:12.912Z","correlation_id":"iCv1CEjqcG3","author_id":1,"entity_id":10,"entity_type":"Project","add":"project","author_name":"Harry Potter","target_id":"root/tanuki-rails","target_type":"Project","target_details":"root/tanuki-rails","ip_address":"127.0.0.1","entity_path":"root/tanuki-rails"}
log/audit_json.log:{"severity":"INFO","time":"2020-03-11T01:04:14.983Z","correlation_id":"iCv1CEjqcG3","author_id":1,"entity_id":10,"entity_type":"Project","add":"protected_branch","author_name":"Harry Potter","target_id":1,"target_type":"ProtectedBranch","target_details":"master","push_access_levels":["Maintainers"],"merge_access_levels":["Maintainers"],"ip_address":"127.0.0.1","entity_path":"root/tanuki-rails"}
Output of checks
This bug happens on GitLab.com
Possible fixes
As per sequence diagram below, it is quite obvious that Projects::CreateService
has been invoked twice (1 and 7), each time causes a number of duplicated actions being executed. Audit event recording is one of them.
Points for consideration:
- Eliminate the awkward cyclic dependency on
Projects::CreateService
that could potential cause more issues
Edited by 🤖 GitLab Bot 🤖