Skip to content

Improve storage notification alerts

Sheldon Led requested to merge led/371674-improve-repo-limit-alert into master

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:

  1. 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
  2. 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

  1. Repository enforcement:
    1. User is approaching free tier limit in one of the projects: we don't notify at this stage
    2. User reached free tier limit in one of the projects: we show the variation 1 of the alert (first item in the screenshots table below)
    3. One or more projects are consuming all the purchased storage: we show the warning alert, variation 2
    4. The user has consumed all purchased storage: we show the error alert, variation 3
  2. Namespace enforcement:
    1. User is approaching free tier limit for the namespace: we show the warning alert, variation 2
    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
    3. User purchased additional storage but it's almost over: we show the warning alert, variation 2;
    4. The user has consumed all purchased storage: we show the error alert, variation 3

Improvements for each use case

In all scenarios we now:

  1. Show the alert for owners and maintainers
    1. 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
  2. Hide the Purchase more storage button for non-owners, since they won't have the permissions to buy storage anyway
  3. Hide the View usage details button for non-owners, since they don't have access to Usage Quotas Page anyway
  4. Change the CTA copy basing on the user role:
    1. For owners we guide them to purchase more storage
    2. For non-owners we advise them to find an owner and ask them to purchase more storage
  5. 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:

  1. Repository enforcement:
    1. Still not notifying in this scenario
    2. The "Reduce storage" copy is more targeted to types that actually impact the total (git repository and git LFS)
    3. 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)
    4. Using the standard title with percentage. Clearer message indicating that only projects over the free tier limit are locked.
  2. Namespace enforcement:
    1. Clearer CTA copy, guiding user to reduce storage or purchase additional storage
    2. Clearer title, indicating that this is the free tier limit.
    3. Same as scenario 1
    4. As with other namespace enforcement alerts, we have 2 links:
      1. Manage your storage usage: https://docs.gitlab.com/ee/user/usage_quotas.html#manage-your-storage-usage
      2. FAQ: https://about.gitlab.com/pricing/#what-happens-if-i-exceed-my-storage-and-transfer-limits

Hope the explanation above makes it easier to navigate through the screenshots below.

Screenshots or screen recordings

Before

Repository Limit Alerts Namespace Limit Alerts
Project over free tier limit and no purchased storage repo_storage_over_limit_no_purchased_storage ---
Project over free tier limit; with purchased storage; under purchased limit repo_storage_over_limit_with_purchased_storage_under_limit Namespace storage; with or without purchased storage; under total limit namespcace_storage_under_limit
Project over free tier limit; with purchased storage; over purchased limit repo_storage_over_limit_with_purchased_storage_over_limit Namespace storage; with or without purchased storage; over total limit namespcace_storage_over_limit

After - User with owner access

Repository Limit Alerts Namespace Limit Alerts
Project over free tier limit and no purchased storage repo_storage_over_limit_no_purchased_storage_after_owner Namespace over free tier limit and no purchased storage namespace_storage_over_limit_no_purchased_storage_after_owner
Project over free tier limit; with purchased storage; under purchased limit repo_storage_over_limit_with_purchased_storage_under_limit_after_owner Namespace storage; with or without purchased storage; under total limit namespcace_storage_under_limit_owner
Project over free tier limit; with purchased storage; over purchased limit repo_storage_over_limit_with_purchased_storage_over_limit_after_owner Namespace storage; with purchased storage; over total limit namespcace_storage_over_limit_after_owner

After - User with any non-owner access

Repository Limit Alerts Namespace Limit Alerts
Project over free tier limit and no purchased storage repo_storage_over_limit_no_purchased_storage_after_maintainer Namespace over free tier limit and no purchased storage namespace_storage_over_limit_no_purchased_storage_after_maintainer
Project over free tier limit; with purchased storage; under purchased limit repo_storage_over_limit_with_purchased_storage_under_limit_after_maintainer Namespace storage; with or without purchased storage; under total limit namespcace_storage_under_limit_maintainer
Project over free tier limit; with purchased storage; over purchased limit repo_storage_over_limit_with_purchased_storage_over_limit_after_maintainer Namespace storage; with purchased storage; over total limit namespcace_storage_over_limit_after_maintainer

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

Watch the video

Note: some parts of this are cached. Here are the instructions to clear cache:

  1. Invalidate redis cache:
    1. On your terminal, go to your gitlab project folder
    2. Execute: rails cache:clear
    3. This might take over a minute
  2. Invalidate strong_memoize:
    1. On your terminal, go to your gitlab project folder
    2. Open rails console: rails c
    3. 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

  1. Initial setup:
    1. Disable Feature Flags
    2. 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 😅 )
    3. Create a Group and a Project to work with. Take note of their IDs

Now for each type of alert:

  1. Project over free tier limit and no purchased storage
    1. Make sure you don't have purchased storage: Group.find(<group id>).update(additional_purchased_storage_size: 0)
    2. Add enough storage to your project so that it goes over the free tier limit:
      1. If you refer to the docs, it's the 4th row of the 1st column.
      2. Change rough_percentage_used in the script to 110 for example
  2. Project over free tier limit; with purchased storage; under purchased limit
    1. Use the same project as above, add purchased storage
    2. If you refer to the docs, it's the 5th row of the 1st column.
    3. Copy and paste the script as is (update only the Group ID part)
  3. Project over free tier limit; with purchased storage; over purchased limit
    1. Use the same project as above, change purchased storage
    2. If you refer to the docs, it's the 5th row of the 1st column.
    3. Change rough_percentage_used in the script to 110 for example

2. Namespace limits

  1. Initial setup:
    1. Enable Feature Flags and Application Setting
    2. 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 😅 )
    3. Create a Group and a Project to work with. Take note of their IDs

Now for each type of alert:

  1. Namespace storage; with or without purchased storage; under total limit
    1. Add some namespace storage
    2. If you refer to the docs, it's the 4th row of the 2nd column.
    3. Copy and paste the script as is (update only the Group ID part)
  2. Namespace storage; with or without purchased storage; over total limit
    1. Use the same namespace as above, change your namespace storage
    2. If you refer to the docs, it's the 4th row of the 2nd column.
    3. 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.

Edited by Sheldon Led

Merge request reports