Fix locked nested projects after storage purchase
What does this MR do?
When a namespace exceeds it's storage limit on GitLab.com, certain actions on the projects within are locked - such as pushes, branch creation, etc.
One of the solutions for our customers is to purchase additional storage, which should immediately unlock all the projects within the namespace (assuming enough storage was purchased).
It was reported that this is not always the case, and sometimes a customer's project may not be unlocked after such a purchase - see: customers-gitlab-com#2303 (closed)
This only appears to happen for nested projects, i.e. projects within a sub-group.
This is because when determining if a repository action exceeds the size limit for the namespace via the RepositorySizeChecker, it uses the project's namespace when looking for additional purchased storage via the namespace_limit
, here. But this namespace could be a sub-group which doesn't have the information of the root group's namespace limit.
This is a problem because purchased storage (represented in namespace_limits
entries) can only be linked to a root level namespace (validation here), so when this check is made for a sub-group project, the purchased storage is never identified and thus the project remains locked / actions are blocked.
This MR seeks to address the problem by modifying how the purchased storage is looked up, by using the root ancestor namespace if applicable.
Testing
You can reproduce the issue / test this solution by:
- Create a group with a project
- Create a sub-group
- Create a project in the sub group with at least one file (e.g. 2mb file)
- Set a low repo size limit (e.g. 1mb) so that the storage limit is reached (via Admin > Settings > General > Account and limit > Size limit per repository)
- Purchase a storage pack to unlock the namespace via CustomersDot (if you have it setup, otherwise manually add an entry to
namespace_limit
, instructions below) - Attempt to create a new branch in both root level group project and sub-group project
- See error in sub-group project action
Insert a namespace limit DB entry:
NamespaceLimit.create(
namespace: <Your root namespace>,
additional_purchased_storage_size: 10240,
additional_purchased_storage_ends_on: "2023-12-01"
)
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry -
Documentation (if required) -
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides -
Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. -
Tested in all supported browsers -
Informed Infrastructure department of a default or new setting change, if applicable per definition of done