Improve storage notification alerts
What does this MR do and why?
This MR proposes several improvements for the storage limit notifications. Before describing the changes I want to give some context around the notifications.
First we have 2 types of enforcement:
-
Repository enforcement: also known as Project enforcement, it's the enforcement currently in place, where each project receives a free tier storage quota of
10GB
. Once a given project reaches this limit, an owner of this project's namespace has to buy additional storage for the namespace and each project exceeding the free tier limit will consume from this additional storage - Namespace enforcement: the new enforcement that we're developing where the namespace will have a free tier storage quota, and all projects will consume from this pool. So once a given project consumes all the quota of its namespace, all projects under this namespace will be locked.
This effort started with https://gitlab.com/gitlab-org/gitlab/-/issues/371674 where a few improvements were proposed for the Repository Limit Alert. However after some investigation it was described in https://gitlab.com/gitlab-org/gitlab/-/issues/371674#note_1317858981 that the improvements could be expanded to all notification alerts.
Notification use cases
We have 4 scenarios for each enforcement type
-
Repository enforcement:
-
User is approaching free tier limit in one of the projects
: we don't notify at this stage -
User reached free tier limit in one of the projects
: we show thevariation 1
of the alert (first item in the screenshots table below) -
One or more projects are consuming all the purchased storage
: we show the warning alert,variation 2
-
The user has consumed all purchased storage
: we show the error alert,variation 3
-
-
Namespace enforcement:
-
User is approaching free tier limit for the namespace
: we show the warning alert,variation 2
-
User reached the free tier limit for the namespace
: we show the error alert, before we didn't have specific wording for a namespace without purchased storage -
User purchased additional storage but it's almost over
: we show the warning alert,variation 2
; -
The user has consumed all purchased storage
: we show the error alert,variation 3
-
Improvements for each use case
In all scenarios we now:
- Show the alert for owners and maintainers
- Only exception is for users accessing User Namespaces, in this case we still only show the alert for the owners. If a project belongs to a User Namespace, a maintainer will see the banner when accessing the project page
- Hide the
Purchase more storage
button for non-owners, since they won't have the permissions to buy storage anyway - Hide the
View usage details
button for non-owners, since they don't have access to Usage Quotas Page anyway - Change the CTA copy basing on the user role:
- For owners we guide them to purchase more storage
- For non-owners we advise them to find an owner and ask them to purchase more storage
- The copy gathers some improvements suggested in https://gitlab.com/gitlab-org/gitlab/-/issues/371674#note_1087039440 to be more context specific
Now the improvements for each scenario:
-
Repository enforcement:
- Still not notifying in this scenario
- The "Reduce storage" copy is more targeted to types that actually impact the total (git repository and git LFS)
- Removed the numbers from the title, since they only represent the Total Purchased, not the actual total (because the concept of Total Storage can't be applied here)
- Using the standard title with percentage. Clearer message indicating that only projects over the free tier limit are locked.
-
Namespace enforcement:
- Clearer CTA copy, guiding user to reduce storage or purchase additional storage
- Clearer title, indicating that this is the free tier limit.
- Same as scenario 1
- As with other namespace enforcement alerts, we have 2 links:
Hope the explanation above makes it easier to navigate through the screenshots below.
Screenshots or screen recordings
Before
After - User with owner access
After - User with any non-owner access
How to set up and validate locally
The instructions below are based on this section of the storage docs, you'll find a table that aims to help to differentiate between Namespace vs Repository limits. Please use that table to setup things on your local environment.
I've recorded a YouTube video where I go over each step of the validation
Note: some parts of this are cached. Here are the instructions to clear cache:
- Invalidate
redis
cache:- On your terminal, go to your gitlab project folder
- Execute:
rails cache:clear
- This might take over a minute
-
Invalidate
strong_memoize
:- On your terminal, go to your gitlab project folder
- Open rails console:
rails c
- Create a new instance of the class containing the memoization and clear the necessary key:
Namespaces::Storage::RootExcessSize.new.clear_memoization(:limit)
Important: when testing CLI notifications, some git push
commands will go through, and this will recalculate your project storage. Please be aware of that as it will impact your setup.
1. Repository limits
- Initial setup:
- Disable Feature Flags
- Set your desired
repository_size_limit
amount (I suggest a big number of megabytes (so we can work with integers) and something easy to work with percentages😅 ) - Create a
Group
and aProject
to work with. Take note of theirIDs
Now for each type of alert:
- Project over free tier limit and no purchased storage
- Make sure you don't have purchased storage:
Group.find(<group id>).update(additional_purchased_storage_size: 0)
- Add enough storage to your project so that it goes over the free tier limit:
- If you refer to the docs, it's the 4th row of the 1st column.
- Change
rough_percentage_used
in the script to110
for example
- Make sure you don't have purchased storage:
- Project over free tier limit; with purchased storage; under purchased limit
- Use the same project as above, add purchased storage
- If you refer to the docs, it's the 5th row of the 1st column.
- Copy and paste the script as is (update only the
Group ID
part)
- Project over free tier limit; with purchased storage; over purchased limit
- Use the same project as above, change purchased storage
- If you refer to the docs, it's the 5th row of the 1st column.
- Change
rough_percentage_used
in the script to110
for example
2. Namespace limits
- Initial setup:
- Enable Feature Flags and Application Setting
- Add
storage_size_limit
limits to the free/default plan (I suggest a big number of megabytes (so we can work with integers) and something easy to work with percentages😅 ) - Create a
Group
and aProject
to work with. Take note of theirIDs
Now for each type of alert:
- Namespace storage; with or without purchased storage; under total limit
- Add some namespace storage
- If you refer to the docs, it's the 4th row of the 2nd column.
- Copy and paste the script as is (update only the
Group ID
part)
- Namespace storage; with or without purchased storage; over total limit
- Use the same namespace as above, change your namespace storage
- If you refer to the docs, it's the 4th row of the 2nd column.
- Change
rough_percentage_used
to 110
3. Ok I setup the things above, how can I see the alerts like in the screenshots?
The alerts will show on your group page: https://gdk.test:3443/groups/your-group
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.