Check if namespace storage limit exceeded
We currently calculate root namespace storage statistics with a delay of 1.5h. This gets done in a background job, you can find more how this is done in the namespace storage statics case study.
It's therefore not costly to get the statistics of a namespace because they are pre-calculated. To check if a project exceeds the namespace limit we need to do the following:
- Get the namespace of the project (group or user namespace)
- Get the
root_ancestorof the namespace - Get the
NamespaceStorageStatisticsof that root_namespace. - Get the
namespace_storage_size_limitfromApplicationSettings - Compare the
namespace_storage_size_limitwithstorage_statics.storage_sizedata
Part of https://gitlab.com/gitlab-org/gitlab/-/issues/209119
Edited by Nicolas Dular