Start using RepositoryInfo for repository size usage quota calculations
The current repository size calculations take into account the full repository's size. This includes all data part of a repository:
- References.
- Objects, regardless of their reachability.
- Packfiles, regardless of whether they are cruft packs or not.
- Caches that we need to write to efficiently serve repositories.
In the past, we tried to adapt RepositorySize to start taking these different parts into account so that the end result only accounts for data that is actually user-controllabel. But as documented in Change repository size calculations to provide ... (gitaly#5002 - closed), this had the big downside that we started to encode policy into the RPC instead of providing mechanism.
Gitaly has thus changed direction and implemented a new RPC RepositoryInfo in the context of Use cruft packs to exclude unreachable objects ... (gitaly#4824 - closed). This RPC provides more fine-grained information about the repository and is supposed to be extendable in the future in case new usecases come up.
We should thus move our usage quota calculations to use this new RPC instead of RepositorySize. As documented in gitaly#4824 (comment 1306677369), the current goal is to only account for the size of recent objects.
Implementation plan
- Add
RepositoryInfo
RPC support to Rails application (see old RepositorySize RPC). - Add feature flag to select between old
RepositorySize
and newRepositoryInfo
RPCs for size calculations.
Availability and Testing
Specs that may need to be updated:
spec/lib/gitlab/repository_size_checker_spec.rb
spec/lib/gitlab/repository_size_error_message_spec.rb
spec/services/snippets/repository_validation_service_spec.rb
ee/spec/features/groups/usage_quotas/storage_tab_spec.rb