Create push rules in a lazy way
Description
We create a large amount of PushRule
records that are completely not used.
- We create a "push rule template" on the first access to
admin/push_rule
here - For every new project we create a new record based on this template here
- If we still don't have a push rule for project, we create it on the first access to
settings/repository
here - We have a completely empty push rule template on GitLab.com
- We have 1705258 empty push rules on GitLab.com out of 1710113 total. That's 99.7% unnecessary records.
Proposal
- Create "push rule template" only when the form is submitted
- Create project push rule only when the form is submitted
- Remove all empty push rules with a post deployment migration in the next release after the above changes. This will also remove empty "push rule template" on GitLab.com and prevent us from creating unnecessary records for new projects.
Potential problems
When somebody submits the form on GitLab.com and create an empty "push rule template" we will have the same problem with unnecessary records again. I'm not sure why it may happen but it certainly can happen.